>From 38c5a10a5876ea47766ffc05b5a131a210d6e1aa Mon Sep 17 00:00:00 2001 From: YOSHIFUJI Hideaki Date: Mon, 13 Jul 2015 15:23:02 +0900 Subject: [PATCH] ipv6: Avoid NULL pointer dereference in __ipv6_dev_get_saddr(). Commit 9131f3de2 ("ipv6: Do not iterate over all interfaces when finding source address on specific interface.") introduced possible NULL pointer dereference if outgoing device is specified. Fixes: 9131f3de24db4dc12199aede7d931e6703e97f3b ("ipv6: Do not iterate over all interfaces when finding source address on specific interface.") Signed-off-by: YOSHIFUJI Hideaki --- net/ipv6/addrconf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 4ab74d5..50ad476 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -1480,7 +1480,8 @@ int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev, } if (use_oif_addr) { - __ipv6_dev_get_saddr(net, &dst, prefs, saddr, idev, scores); + if (idev) + __ipv6_dev_get_saddr(net, &dst, prefs, saddr, idev, scores); } else { for_each_netdev_rcu(net, dev) { idev = __in6_dev_get(dev); -- 1.9.1