Skip to contentSkip to conversation

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

PATCH In review [email protected] 3 participants 3 messages Mar 16, 2012 – Mar 17, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: Don't dev_hold(dev) in ip6_mc_find_dev_rcu.

From: RongQing.Li <[email protected]>

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.

---
 net/ipv6/mcast.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
net/ipv6/mcast.c +0 -1
index b853f06..16c33e3 100644
@@ -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
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Le vendredi 16 mars 2012 à 16:54 +0800, [email protected] a écrit :

From: RongQing.Li <[email protected]>

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.

---
 net/ipv6/mcast.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
net/ipv6/mcast.c +0 -0
index b853f06..16c33e3 100644

net/ipv6/mcast.c static struct inet6_dev *ip6_mc_find_dev_rcu(struct net *net, · line 262

Quoted 7 lines
net/ipv6/mcast.c +0 -1
@@ -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)

maintainer
#2 lore raw

From: Eric Dumazet <[email protected]>
Date: Fri, 16 Mar 2012 07:15:53 -0700

Quoted 8 lines · Le vendredi 16 mars 2012 à 16:54 +0800, [email protected] a écrit :
Quoted 7 lines

From: RongQing.Li <[email protected]>

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.

...

Quoted 3 lines

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

Applied and queued up for -stable, thanks.