net/ipv6: Fix a test against 'ipv6_find_idev()' return value
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 28 Dec 2018 22:28:21 +0000 (23:28 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 30 Dec 2018 20:31:17 +0000 (12:31 -0800)
'ipv6_find_idev()' returns NULL on error, not an error pointer.
Update the test accordingly and return -ENOBUFS, as already done in
'addrconf_add_dev()', if NULL is returned.

Fixes: ("ipv6: allow userspace to add IFA_F_OPTIMISTIC addresses")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/addrconf.c

index 521e471f1cf92017933deda65bff1d13ddde0ec2..8eeec6eb2bd3730a7445eabffb06ffb03e82e78f 100644 (file)
@@ -4736,8 +4736,8 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh,
                         IFA_F_MCAUTOJOIN | IFA_F_OPTIMISTIC;
 
        idev = ipv6_find_idev(dev);
-       if (IS_ERR(idev))
-               return PTR_ERR(idev);
+       if (!idev)
+               return -ENOBUFS;
 
        if (!ipv6_allow_optimistic_dad(net, idev))
                cfg.ifa_flags &= ~IFA_F_OPTIMISTIC;