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

[IPV4/IPV6]: Fail registration if inet device construction fails

Now that netdev notifications can fail, we can use this to signal
errors during registration for IPv4/IPv6.  In particular, if we
fail to allocate memory for the inet device, we can fail the netdev
registration.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fcc5a03a
...@@ -1056,10 +1056,9 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, ...@@ -1056,10 +1056,9 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
if (!in_dev) { if (!in_dev) {
if (event == NETDEV_REGISTER) { if (event == NETDEV_REGISTER) {
in_dev = inetdev_init(dev); in_dev = inetdev_init(dev);
if (!in_dev)
return notifier_from_errno(-ENOMEM);
if (dev == &loopback_dev) { if (dev == &loopback_dev) {
if (!in_dev)
panic("devinet: "
"Failed to create loopback\n");
IN_DEV_CONF_SET(in_dev, NOXFRM, 1); IN_DEV_CONF_SET(in_dev, NOXFRM, 1);
IN_DEV_CONF_SET(in_dev, NOPOLICY, 1); IN_DEV_CONF_SET(in_dev, NOPOLICY, 1);
} }
......
...@@ -2256,14 +2256,14 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event, ...@@ -2256,14 +2256,14 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
struct net_device *dev = (struct net_device *) data; struct net_device *dev = (struct net_device *) data;
struct inet6_dev *idev = __in6_dev_get(dev); struct inet6_dev *idev = __in6_dev_get(dev);
int run_pending = 0; int run_pending = 0;
int err;
switch(event) { switch(event) {
case NETDEV_REGISTER: case NETDEV_REGISTER:
if (!idev && dev->mtu >= IPV6_MIN_MTU) { if (!idev && dev->mtu >= IPV6_MIN_MTU) {
idev = ipv6_add_dev(dev); idev = ipv6_add_dev(dev);
if (!idev) if (!idev)
printk(KERN_WARNING "IPv6: add_dev failed for %s\n", return notifier_from_errno(-ENOMEM);
dev->name);
} }
break; break;
case NETDEV_UP: case NETDEV_UP:
...@@ -2373,7 +2373,9 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event, ...@@ -2373,7 +2373,9 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
NULL); NULL);
addrconf_sysctl_register(idev, &idev->cnf); addrconf_sysctl_register(idev, &idev->cnf);
#endif #endif
snmp6_register_dev(idev); err = snmp6_register_dev(idev);
if (err)
return notifier_from_errno(err);
} }
break; break;
} }
......
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