Commit b79d1d54 authored by David S. Miller's avatar David S. Miller

ipv6: Fix result generation in ipv6_get_ifaddr().

Finishing naturally from hlist_for_each_entry(x, ...) does not result
in 'x' being NULL.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b54c9b98
...@@ -1341,9 +1341,9 @@ EXPORT_SYMBOL(ipv6_chk_prefix); ...@@ -1341,9 +1341,9 @@ EXPORT_SYMBOL(ipv6_chk_prefix);
struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *addr, struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *addr,
struct net_device *dev, int strict) struct net_device *dev, int strict)
{ {
struct inet6_ifaddr *ifp = NULL; struct inet6_ifaddr *ifp, *result = NULL;
struct hlist_node *node;
unsigned int hash = ipv6_addr_hash(addr); unsigned int hash = ipv6_addr_hash(addr);
struct hlist_node *node;
rcu_read_lock_bh(); rcu_read_lock_bh();
hlist_for_each_entry_rcu(ifp, node, &inet6_addr_lst[hash], addr_lst) { hlist_for_each_entry_rcu(ifp, node, &inet6_addr_lst[hash], addr_lst) {
...@@ -1352,6 +1352,7 @@ struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *add ...@@ -1352,6 +1352,7 @@ struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *add
if (ipv6_addr_equal(&ifp->addr, addr)) { if (ipv6_addr_equal(&ifp->addr, addr)) {
if (dev == NULL || ifp->idev->dev == dev || if (dev == NULL || ifp->idev->dev == dev ||
!(ifp->scope&(IFA_LINK|IFA_HOST) || strict)) { !(ifp->scope&(IFA_LINK|IFA_HOST) || strict)) {
result = ifp;
in6_ifa_hold(ifp); in6_ifa_hold(ifp);
break; break;
} }
...@@ -1359,7 +1360,7 @@ struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *add ...@@ -1359,7 +1360,7 @@ struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, const struct in6_addr *add
} }
rcu_read_unlock_bh(); rcu_read_unlock_bh();
return ifp; return result;
} }
/* Gets referenced address, destroys ifaddr */ /* Gets referenced address, destroys ifaddr */
......
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