Skip to contentSkip to conversation

bridge: remove dev_put() in add_del_if()

PATCH Applied Eric Dumazet 3 participants 4 messages Nov 4, 2009 – Nov 6, 2009

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

PATCH 1/1 bridge: remove dev_put() in add_del_if()

add_del_if() is called with RTNL, we can use __dev_get_by_index() instead of [dev_get_by_index() + dev_put()]

---
 net/bridge/br_ioctl.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
net/bridge/br_ioctl.c +2 -2
index 6a6433d..2af6e4a 100644
@@ -81,6 +81,7 @@ static int get_fdb_entries(struct net_bridge *br, void __user *userbuf,
 	return num;
 }
 
+/* called with RTNL */
 static int add_del_if(struct net_bridge *br, int ifindex, int isadd)
 {
 	struct net_device *dev;
@@ -89,7 +90,7 @@ static int add_del_if(struct net_bridge *br, int ifindex, int isadd)
 	if (!capable(CAP_NET_ADMIN))
 		return -EPERM;
 
-	dev = dev_get_by_index(dev_net(br->dev), ifindex);
+	dev = __dev_get_by_index(dev_net(br->dev), ifindex);
 	if (dev == NULL)
 		return -EINVAL;
 
@@ -98,7 +99,6 @@ static int add_del_if(struct net_bridge *br, int ifindex, int isadd)
 	else
 		ret = br_del_if(br, dev);
 
-	dev_put(dev);
 	return ret;
 }
 
Acked-by on v1 1/1
#1 lore raw
Quoted 30 lines · On Wed, 04 Nov 2009 20:09:07 +0100 Eric Dumazet <[email protected]> wrote:

add_del_if() is called with RTNL, we can use __dev_get_by_index() instead of [dev_get_by_index() + dev_put()]

---
 net/bridge/br_ioctl.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
net/bridge/br_ioctl.c +2 -1
index 6a6433d..2af6e4a 100644
@@ -81,6 +81,7 @@ static int get_fdb_entries(struct net_bridge *br, void __user *userbuf,
 	return num;
 }
 
+/* called with RTNL */
 static int add_del_if(struct net_bridge *br, int ifindex, int isadd)
 {
 	struct net_device *dev;
@@ -89,7 +90,7 @@ static int add_del_if(struct net_bridge *br, int ifindex, int isadd)
 	if (!capable(CAP_NET_ADMIN))
 		return -EPERM;
 
-	dev = dev_get_by_index(dev_net(br->dev), ifindex);
+	dev = __dev_get_by_index(dev_net(br->dev), ifindex);
 	if (dev == NULL)
 		return -EINVAL;
 

net/bridge/br_ioctl.c static int add_del_if(struct net_bridge *br, int ifindex, int isadd) · line 104

Quoted 7 lines
net/bridge/br_ioctl.c +0 -1
@@ -98,7 +99,6 @@ static int add_del_if(struct net_bridge *br, int ifindex, int isadd)
 	else
 		ret = br_del_if(br, dev);
 
-	dev_put(dev);
 	return ret;
 }
 

As part of the general ref count purge sure.

#2 lore raw
Quoted 4 lines · Stephen Hemminger

As part of the general ref count purge sure.

Yes, sure... but nf_queue.c is such an abuser that I doubt we really can make dev_put() doing the atomic_dec_test() one day...

maintainer Applied
#3 lore raw
In reply to Stephen Hemminger

From: Stephen Hemminger <[email protected]>
Date: Wed, 4 Nov 2009 11:40:20 -0800

Quoted 7 lines
Quoted 4 lines · On Wed, 04 Nov 2009 20:09:07 +0100 Eric Dumazet <[email protected]> wrote:

add_del_if() is called with RTNL, we can use __dev_get_by_index() instead of [dev_get_by_index() + dev_put()]

...

Quoted 3 lines

As part of the general ref count purge sure.

Applied, thanks everyone.