From: Eric Dumazet Date: Tue, 19 Oct 2010 00:39:18 +0000 (+0000) Subject: net: avoid a dev refcount in ip_mc_find_dev() X-Git-Tag: MMI-PSA29.97-13-9~21994^2~86 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9e917dca74138cccf398ce8bb924c7fd2980ec1d;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git net: avoid a dev refcount in ip_mc_find_dev() We hold RTNL in ip_mc_find_dev(), no need to touch device refcount. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 3df057e89640..36e27c2107de 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -153,7 +153,7 @@ static void fib_flush(struct net *net) * @addr: the source address * @devref: if true, take a reference on the found device * - * If a caller uses devref=false, it should be protected by RCU + * If a caller uses devref=false, it should be protected by RCU, or RTNL */ struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref) { diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 25f339672b28..a525328ec372 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -1418,6 +1418,7 @@ void ip_mc_destroy_dev(struct in_device *in_dev) write_unlock_bh(&in_dev->mc_list_lock); } +/* RTNL is locked */ static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) { struct flowi fl = { .nl_u = { .ip4_u = @@ -1433,10 +1434,9 @@ static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) return idev; } if (imr->imr_address.s_addr) { - dev = ip_dev_find(net, imr->imr_address.s_addr); + dev = __ip_dev_find(net, imr->imr_address.s_addr, false); if (!dev) return NULL; - dev_put(dev); } if (!dev && !ip_route_output_key(net, &rt, &fl)) {