Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1480937 > unrolled thread

[PATCH] net: inet: diag: Fix an error handling

Started byChristophe JAILLET <christophe.jaillet@wanadoo.fr>
First post2016-09-12 08:10 +0200
Last post2016-09-12 20:30 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net: inet: diag: Fix an error handling Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-09-12 08:10 +0200
    Re: [PATCH] net: inet: diag: Fix an error handling David Ahern <dsa@cumulusnetworks.com> - 2016-09-12 16:40 +0200
      Re: [PATCH] net: inet: diag: Fix an error handling Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-09-12 20:30 +0200

#1480937 — [PATCH] net: inet: diag: Fix an error handling

FromChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Date2016-09-12 08:10 +0200
Subject[PATCH] net: inet: diag: Fix an error handling
Message-ID<sgsBj-7Yg-13@gated-at.bofh.it>
If 'inet_diag_lock_handler()' returns an error, we should not call
'inet_diag_unlock_handler()' on it.
'handler' is not a valid mutexc in this case.

This has been spotted with the folowing coccinelle script:
////////////////////////////
@@
expression x;
identifier f;
@@

*   if (IS_ERR(x))
    {
       ...
*      f(<+... x ...+>);
       ...
    }

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 net/ipv4/inet_diag.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index abfbe492ebfe..795af25cf84c 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -1134,7 +1134,6 @@ int inet_diag_handler_get_info(struct sk_buff *skb, struct sock *sk)
 
 	handler = inet_diag_lock_handler(sk->sk_protocol);
 	if (IS_ERR(handler)) {
-		inet_diag_unlock_handler(handler);
 		nlmsg_cancel(skb, nlh);
 		return PTR_ERR(handler);
 	}
-- 
2.7.4

[toc] | [next] | [standalone]


#1481363

FromDavid Ahern <dsa@cumulusnetworks.com>
Date2016-09-12 16:40 +0200
Message-ID<sgAyS-4vI-49@gated-at.bofh.it>
In reply to#1480937
On 9/12/16 12:02 AM, Christophe JAILLET wrote:
> diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
> index abfbe492ebfe..795af25cf84c 100644
> --- a/net/ipv4/inet_diag.c
> +++ b/net/ipv4/inet_diag.c
> @@ -1134,7 +1134,6 @@ int inet_diag_handler_get_info(struct sk_buff *skb, struct sock *sk)
>  
>  	handler = inet_diag_lock_handler(sk->sk_protocol);
>  	if (IS_ERR(handler)) {
> -		inet_diag_unlock_handler(handler);
>  		nlmsg_cancel(skb, nlh);
>  		return PTR_ERR(handler);
>  	}
> 

That call is needed. inet_diag_unlock_handler does not operate on the input arg but a global mutex. Perhaps a better patch is to change inet_diag_unlock_handler() to a void.

[toc] | [prev] | [next] | [standalone]


#1481806

FromChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Date2016-09-12 20:30 +0200
Message-ID<sgE9s-6Zj-49@gated-at.bofh.it>
In reply to#1481363
Le 12/09/2016 à 16:35, David Ahern a écrit :
> On 9/12/16 12:02 AM, Christophe JAILLET wrote:
>> diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
>> index abfbe492ebfe..795af25cf84c 100644
>> --- a/net/ipv4/inet_diag.c
>> +++ b/net/ipv4/inet_diag.c
>> @@ -1134,7 +1134,6 @@ int inet_diag_handler_get_info(struct sk_buff *skb, struct sock *sk)
>>   
>>   	handler = inet_diag_lock_handler(sk->sk_protocol);
>>   	if (IS_ERR(handler)) {
>> -		inet_diag_unlock_handler(handler);
>>   		nlmsg_cancel(skb, nlh);
>>   		return PTR_ERR(handler);
>>   	}
>>
> That call is needed. inet_diag_unlock_handler does not operate on the input arg but a global mutex. Perhaps a better patch is to change inet_diag_unlock_handler() to a void.
This is obvious. Sorry for the noise.

CJ

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web