net: bridge: fix net device refcount tracking issue in error path
Subsystems (3)
PATCH 1/1 net: bridge: fix net device refcount tracking issue in error path
From: Eric Dumazet <[email protected]>
I left one dev_put() in br_add_if() error path and sure enough syzbot found its way.
As the tracker is allocated in new_nbp(), we must make sure to properly free it.
We have to call dev_put_track(dev, &p->dev_tracker) before @p object is freed, of course. This is not an issue because br_add_if() owns a reference on @dev.
--- net/bridge/br_if.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bridge/br_if.c +2 -1
@@ -615,6 +615,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev, err =dev_set_allmulti (dev,1 );if (err) {br_multicast_del_port (p); +dev_put_track (dev, &p->dev_tracker);kfree (p);/* kobject not yet init'd, manually free */ goto err1; }
@@ -724,10 +725,10 @@ int br_add_if(struct net_bridge *br, struct net_device *dev,sysfs_remove_link (br->ifobj, p->dev->name); err2:br_multicast_del_port (p); +dev_put_track (dev, &p->dev_tracker);kobject_put (&p->kobj);dev_set_allmulti (dev,-1 ); err1: -dev_put (dev);return err; }
Signature · 1 line
2.34.1.575.g55b058a8bb-goog
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 9 lines · On Wed, 12 Jan 2022 04:53:00 -0800 you wrote:
From: Eric Dumazet <[email protected]>
I left one
dev_put()inbr_add_if()error path and sure enough syzbot found its way.As the tracker is allocated in
new_nbp(), we must make sure to properly free it.[...]
Here is the summary with links:
- [net] net: bridge: fix net device refcount tracking issue in error path
https://git.kernel.org/netdev/net/c/fcfb894d5952
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html