Commit 7ce1b0ed authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[NET]: Call uninit if necessary in register_netdevice

This patch makes register_netdevice call dev->uninit if the regsitration
fails after dev->init has completed successfully.  Very few drivers use
the init/uninit calls but at least one (drivers/net/wan/sealevel.c) may
leak without this change.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ccc7911f
...@@ -3337,7 +3337,7 @@ int register_netdevice(struct net_device *dev) ...@@ -3337,7 +3337,7 @@ int register_netdevice(struct net_device *dev)
if (!dev_valid_name(dev->name)) { if (!dev_valid_name(dev->name)) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto err_uninit;
} }
dev->ifindex = dev_new_index(); dev->ifindex = dev_new_index();
...@@ -3351,7 +3351,7 @@ int register_netdevice(struct net_device *dev) ...@@ -3351,7 +3351,7 @@ int register_netdevice(struct net_device *dev)
= hlist_entry(p, struct net_device, name_hlist); = hlist_entry(p, struct net_device, name_hlist);
if (!strncmp(d->name, dev->name, IFNAMSIZ)) { if (!strncmp(d->name, dev->name, IFNAMSIZ)) {
ret = -EEXIST; ret = -EEXIST;
goto out; goto err_uninit;
} }
} }
...@@ -3411,7 +3411,7 @@ int register_netdevice(struct net_device *dev) ...@@ -3411,7 +3411,7 @@ int register_netdevice(struct net_device *dev)
ret = netdev_register_sysfs(dev); ret = netdev_register_sysfs(dev);
if (ret) if (ret)
goto out; goto err_uninit;
dev->reg_state = NETREG_REGISTERED; dev->reg_state = NETREG_REGISTERED;
/* /*
...@@ -3436,6 +3436,11 @@ int register_netdevice(struct net_device *dev) ...@@ -3436,6 +3436,11 @@ int register_netdevice(struct net_device *dev)
out: out:
return ret; return ret;
err_uninit:
if (dev->uninit)
dev->uninit(dev);
goto out;
} }
/** /**
......
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