[PATCH net-next v3 2/8] gtp: switch from struct socket to struct sock for the GTP sockets

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/osmocom-net-gprs@lists.osmocom.org/.

Andreas Schultz aschultz at tpip.net
Wed Feb 15 07:04:56 UTC 2017


----- On Feb 14, 2017, at 6:48 PM, David S. Miller davem at davemloft.net wrote:

> From: Andreas Schultz <aschultz at tpip.net>
> Date: Mon, 13 Feb 2017 16:36:18 +0100
> 
>> +	if (gtp->sk0) {
>> +		udp_sk(gtp->sk0)->encap_type = 0;
>> +		rcu_assign_sk_user_data(gtp->sk0, NULL);
>> +		sock_put(gtp->sk0);
>>  	}
> 
> This does "sock_put(NULL);" because you are assigning gtp->sk0 to
> NULL before the sock_put() call.  So you are leaking the socket,
> at best.

I don't understand how this should happen. If I where to use rcu_assign_pointer,
then yes, but rcu_assign_sk_user_data does assign to the sk_user_data member
of struct sock and not to the argument itself.

Andreas



More information about the osmocom-net-gprs mailing list