diff options
author | Eric Dumazet <edumazet@google.com> | 2022-01-12 04:53:00 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-01-12 14:44:18 +0000 |
commit | fcfb894d5952786db3b2b2b9cd3a95cdcedb6ff0 (patch) | |
tree | 9a19318c08a4c63c3cf8d7183397293ea6c37486 /net/bridge/br_if.c | |
parent | 0bbed88af55ed804d19aeb23b32b72b29e1435ee (diff) | |
download | linux-fcfb894d5952786db3b2b2b9cd3a95cdcedb6ff0.tar.gz linux-fcfb894d5952786db3b2b2b9cd3a95cdcedb6ff0.tar.bz2 linux-fcfb894d5952786db3b2b2b9cd3a95cdcedb6ff0.zip |
net: bridge: fix net device refcount tracking issue in error path
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.
Fixes: b2dcdc7f731d ("net: bridge: add net device refcount tracker")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_if.c')
-rw-r--r-- | net/bridge/br_if.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index a52ad81596b7..55f47cadb114 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -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 @@ err3: 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; } |