diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index abf6352..dc77e91 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -401,8 +401,11 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa) ASSERT_RTNL(); if (!in_dev) { - inet_free_ifa(ifa); - return -ENOBUFS; + in_dev = inetdev_init(dev); + if (!in_dev) { + inet_free_ifa(ifa); + return -ENOBUFS; + } } ipv4_devconf_setall(in_dev); if (ifa->ifa_dev != in_dev) { @@ -514,8 +517,11 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh) in_dev = __in_dev_get_rtnl(dev); if (in_dev == NULL) { - err = -ENOBUFS; - goto errout; + in_dev = inetdev_init(dev); + if (!in_dev) { + err = -ENOBUFS; + goto errout; + } } ipv4_devconf_setall(in_dev);