Commit 55b7ab11 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

net: vlan: avoid leaks on register_vlan_dev() failures

VLAN checks for NETREG_UNINITIALIZED to distinguish between
registration failure and unregistration in progress.

Since commit cb626bf5 ("net-sysfs: Fix reference count leak")
registration failure may, however, result in NETREG_UNREGISTERED
as well as NETREG_UNINITIALIZED.

This fix is similer to cebb6975 ("rtnetlink: Fix
memory(net_device) leak when ->newlink fails")

Fixes: cb626bf5 ("net-sysfs: Fix reference count leak")
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cf072069
......@@ -284,7 +284,8 @@ static int register_vlan_device(struct net_device *real_dev, u16 vlan_id)
return 0;
out_free_newdev:
if (new_dev->reg_state == NETREG_UNINITIALIZED)
if (new_dev->reg_state == NETREG_UNINITIALIZED ||
new_dev->reg_state == NETREG_UNREGISTERED)
free_netdev(new_dev);
return err;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment