diff mbox series

[1/3] ipv4: icmp: use icmp_sk_exit()

Message ID 20190222015800.192135-1-wangkefeng.wang@huawei.com
State Changes Requested
Delegated to: David Miller
Headers show
Series [1/3] ipv4: icmp: use icmp_sk_exit() | expand

Commit Message

Kefeng Wang Feb. 22, 2019, 1:57 a.m. UTC
Simply use icmp_sk_exit() when inet_ctl_sock_create() fail in icmp_sk_init().

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 net/ipv4/icmp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Eric Dumazet Feb. 22, 2019, 5:11 p.m. UTC | #1
On 02/21/2019 05:57 PM, Kefeng Wang wrote:
> Simply use icmp_sk_exit() when inet_ctl_sock_create() fail in icmp_sk_init().
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  net/ipv4/icmp.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
> index 065997f414e6..364cfe5e414b 100644
> --- a/net/ipv4/icmp.c
> +++ b/net/ipv4/icmp.c
> @@ -1245,9 +1245,7 @@ static int __net_init icmp_sk_init(struct net *net)
>  	return 0;
>  
>  fail:
> -	for_each_possible_cpu(i)
> -		inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv4.icmp_sk, i));
> -	free_percpu(net->ipv4.icmp_sk);
> +	icmp_sk_exit(net);
>  	return err;
>  }
>  
> 


I do not like this. Future changes in icmp_sk_exit() might trigger a bug in this seldom tested path.
Eric Dumazet Feb. 22, 2019, 5:16 p.m. UTC | #2
On 02/22/2019 09:11 AM, Eric Dumazet wrote:
> 
> 
> On 02/21/2019 05:57 PM, Kefeng Wang wrote:
>> Simply use icmp_sk_exit() when inet_ctl_sock_create() fail in icmp_sk_init().
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>>  net/ipv4/icmp.c | 4 +---
>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
>> index 065997f414e6..364cfe5e414b 100644
>> --- a/net/ipv4/icmp.c
>> +++ b/net/ipv4/icmp.c
>> @@ -1245,9 +1245,7 @@ static int __net_init icmp_sk_init(struct net *net)
>>  	return 0;
>>  
>>  fail:
>> -	for_each_possible_cpu(i)
>> -		inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv4.icmp_sk, i));
>> -	free_percpu(net->ipv4.icmp_sk);
>> +	icmp_sk_exit(net);
>>  	return err;
>>  }
>>  
>>
> 
> 
> I do not like this. Future changes in icmp_sk_exit() might trigger a bug in this seldom tested path.
> 

Oh I see the next patches, now it makes sense.

Please send a proper patch series, with a cover letter, so that it is obvious.

Also you need to include "net-next" instead of plain [PATCH] to express this targets net-next tree.

Carefully read Documentation/networking/netdev-FAQ.rst

Thank you.
diff mbox series

Patch

diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 065997f414e6..364cfe5e414b 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -1245,9 +1245,7 @@  static int __net_init icmp_sk_init(struct net *net)
 	return 0;
 
 fail:
-	for_each_possible_cpu(i)
-		inet_ctl_sock_destroy(*per_cpu_ptr(net->ipv4.icmp_sk, i));
-	free_percpu(net->ipv4.icmp_sk);
+	icmp_sk_exit(net);
 	return err;
 }