Patchwork ipv6: Don't dev_hold(dev) in ip6_mc_find_dev_rcu.

login
register
mail settings
Submitter roy.qing.li@gmail.com
Date March 16, 2012, 8:54 a.m.
Message ID <1331888054-21072-1-git-send-email-roy.qing.li@gmail.com>
Download mbox | patch
Permalink /patch/147158/
State Accepted
Delegated to: David Miller
Headers show

Comments

roy.qing.li@gmail.com - March 16, 2012, 8:54 a.m.
From: RongQing.Li <roy.qing.li@gmail.com>

ip6_mc_find_dev_rcu() is called with rcu_read_lock(), so don't
need to dev_hold().
With dev_hold(), not corresponding dev_put(), will lead to leak.

Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>
---
 net/ipv6/mcast.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
Eric Dumazet - March 16, 2012, 2:15 p.m.
Le vendredi 16 mars 2012 à 16:54 +0800, roy.qing.li@gmail.com a écrit :
> From: RongQing.Li <roy.qing.li@gmail.com>
> 
> ip6_mc_find_dev_rcu() is called with rcu_read_lock(), so don't
> need to dev_hold().
> With dev_hold(), not corresponding dev_put(), will lead to leak.
> 
> Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>
> ---
>  net/ipv6/mcast.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
> index b853f06..16c33e3 100644
> --- a/net/ipv6/mcast.c
> +++ b/net/ipv6/mcast.c
> @@ -257,7 +257,6 @@ static struct inet6_dev *ip6_mc_find_dev_rcu(struct net *net,
>  
>  		if (rt) {
>  			dev = rt->dst.dev;
> -			dev_hold(dev);
>  			dst_release(&rt->dst);
>  		}
>  	} else

Nice catch, bug introduced in 96b52e61be1 (ipv6: mcast: RCU conversions)

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - March 17, 2012, 4:57 a.m.
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 16 Mar 2012 07:15:53 -0700

> Le vendredi 16 mars 2012 à 16:54 +0800, roy.qing.li@gmail.com a écrit :
>> From: RongQing.Li <roy.qing.li@gmail.com>
>> 
>> ip6_mc_find_dev_rcu() is called with rcu_read_lock(), so don't
>> need to dev_hold().
>> With dev_hold(), not corresponding dev_put(), will lead to leak.
>> 
>> Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>
 ...
> Nice catch, bug introduced in 96b52e61be1 (ipv6: mcast: RCU conversions)
> 
> Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

Applied and queued up for -stable, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index b853f06..16c33e3 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -257,7 +257,6 @@  static struct inet6_dev *ip6_mc_find_dev_rcu(struct net *net,
 
 		if (rt) {
 			dev = rt->dst.dev;
-			dev_hold(dev);
 			dst_release(&rt->dst);
 		}
 	} else