Message ID | 20201231034027.1570026-1-kuba@kernel.org (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] net: vlan: avoid leaks on register_vlan_dev() failures | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 5 of 5 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 9 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
From: Jakub Kicinski <kuba@kernel.org> Date: Wed, 30 Dec 2020 19:40:27 -0800 > VLAN checks for NETREG_UNINITIALIZED to distinguish between > registration failure and unregistration in progress. > > Since commit cb626bf566eb ("net-sysfs: Fix reference count leak") > registration failure may, however, result in NETREG_UNREGISTERED > as well as NETREG_UNINITIALIZED. > > This fix is similer to cebb69754f37 ("rtnetlink: Fix > memory(net_device) leak when ->newlink fails") > > Fixes: cb626bf566eb ("net-sysfs: Fix reference count leak") > Signed-off-by: Jakub Kicinski <kuba@kernel.org> > --- > Found by code inspection and compile-tested only. This entire area is inconsistent, and confusing at best. Applied and queued up for -stable, thanks.
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index f292e0267bb9..15bbfaf943fd 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -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; }
VLAN checks for NETREG_UNINITIALIZED to distinguish between registration failure and unregistration in progress. Since commit cb626bf566eb ("net-sysfs: Fix reference count leak") registration failure may, however, result in NETREG_UNREGISTERED as well as NETREG_UNINITIALIZED. This fix is similer to cebb69754f37 ("rtnetlink: Fix memory(net_device) leak when ->newlink fails") Fixes: cb626bf566eb ("net-sysfs: Fix reference count leak") Signed-off-by: Jakub Kicinski <kuba@kernel.org> --- Found by code inspection and compile-tested only. net/8021q/vlan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)