net: fix a leak in register_netdevice()

We have to free "dev->name_node" on this error path.

Fixes: ff92741270 ("net: introduce name_node struct to be used in hashlist")
Reported-by: syzbot+6e13e65ffbaa33757bcb@syzkaller.appspotmail.com
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Dan Carpenter 2019-12-03 17:12:39 +03:00 committed by David S. Miller
parent 56e7a2f83d
commit 42c17fa69f
1 changed files with 3 additions and 3 deletions

View File

@ -9246,7 +9246,7 @@ int register_netdevice(struct net_device *dev)
if (ret) {
if (ret > 0)
ret = -EIO;
goto out;
goto err_free_name;
}
}
@ -9361,12 +9361,12 @@ int register_netdevice(struct net_device *dev)
return ret;
err_uninit:
if (dev->name_node)
netdev_name_node_free(dev->name_node);
if (dev->netdev_ops->ndo_uninit)
dev->netdev_ops->ndo_uninit(dev);
if (dev->priv_destructor)
dev->priv_destructor(dev);
err_free_name:
netdev_name_node_free(dev->name_node);
goto out;
}
EXPORT_SYMBOL(register_netdevice);