diff options
| author | Jakub Kicinski <kuba@kernel.org> | 2020-12-30 19:40:27 -0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-01-17 13:58:58 +0100 |
| commit | 1f8b4552e300762727318a1a8a78e4dc8ffe5138 (patch) | |
| tree | 84fa875a3d4b82a59b5c81de238561b1decd105f /net | |
| parent | 51d3a640509a8c3d1ba6efd1b42d3344d4ef5b75 (diff) | |
| download | linux-1f8b4552e300762727318a1a8a78e4dc8ffe5138.tar.gz linux-1f8b4552e300762727318a1a8a78e4dc8ffe5138.tar.bz2 linux-1f8b4552e300762727318a1a8a78e4dc8ffe5138.zip | |
net: vlan: avoid leaks on register_vlan_dev() failures
[ Upstream commit 55b7ab1178cbf41f979ff83236d3321ad35ed2ad ]
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
| -rw-r--r-- | net/8021q/vlan.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index cf82d970b0e4..0efdf83f78e7 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -272,7 +272,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; } |
