diff options
author | Herbert Xu | 2007-07-30 16:29:40 -0700 |
---|---|---|
committer | David S. Miller | 2007-07-31 02:28:12 -0700 |
commit | 7ce1b0edcb11f90f6fc5e0ceecff467f329889a0 (patch) | |
tree | 75f3a4288c0045e2cbbc0a63608203be0423be89 /net/core | |
parent | ccc7911fbd1c5af9b60453d3a8cca0a36402fee5 (diff) |
[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: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 8c9518e946fa..7bfea5e9030e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3337,7 +3337,7 @@ int register_netdevice(struct net_device *dev) if (!dev_valid_name(dev->name)) { ret = -EINVAL; - goto out; + goto err_uninit; } dev->ifindex = dev_new_index(); @@ -3351,7 +3351,7 @@ int register_netdevice(struct net_device *dev) = hlist_entry(p, struct net_device, name_hlist); if (!strncmp(d->name, dev->name, IFNAMSIZ)) { ret = -EEXIST; - goto out; + goto err_uninit; } } @@ -3411,7 +3411,7 @@ int register_netdevice(struct net_device *dev) ret = netdev_register_sysfs(dev); if (ret) - goto out; + goto err_uninit; dev->reg_state = NETREG_REGISTERED; /* @@ -3436,6 +3436,11 @@ int register_netdevice(struct net_device *dev) out: return ret; + +err_uninit: + if (dev->uninit) + dev->uninit(dev); + goto out; } /** |