aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/addrconf.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2010-03-20 19:18:00 -0400
committerDavid S. Miller <davem@davemloft.net>2010-03-20 19:18:00 -0400
commit3e81c6da39a265e11ef48f52bd15bf7ca0068c75 (patch)
tree880e2887173a0ec9c744bf1848b4e28da3c23558 /net/ipv6/addrconf.c
parentb2db756449f63f98049587f7ede4a8e85e0c79b1 (diff)
ipv6: Fix bug in ipv6_chk_same_addr().
hlist_for_each_entry(p...) will not necessarily initialize 'p' to anything if the hlist is empty. GCC notices this and emits a warning. Just return true explicitly when we hit a match, and return false is we fall out of the loop without one. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/addrconf.c')
-rw-r--r--net/ipv6/addrconf.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 7d7d4b17c0f0..68e5809a2153 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -155,8 +155,8 @@ static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
155 155
156static void inet6_prefix_notify(int event, struct inet6_dev *idev, 156static void inet6_prefix_notify(int event, struct inet6_dev *idev,
157 struct prefix_info *pinfo); 157 struct prefix_info *pinfo);
158static int ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr, 158static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
159 struct net_device *dev); 159 struct net_device *dev);
160 160
161static ATOMIC_NOTIFIER_HEAD(inet6addr_chain); 161static ATOMIC_NOTIFIER_HEAD(inet6addr_chain);
162 162
@@ -1295,23 +1295,22 @@ int ipv6_chk_addr(struct net *net, struct in6_addr *addr,
1295} 1295}
1296EXPORT_SYMBOL(ipv6_chk_addr); 1296EXPORT_SYMBOL(ipv6_chk_addr);
1297 1297
1298static 1298static bool ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
1299int ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr, 1299 struct net_device *dev)
1300 struct net_device *dev)
1301{ 1300{
1301 unsigned int hash = ipv6_addr_hash(addr);
1302 struct inet6_ifaddr *ifp; 1302 struct inet6_ifaddr *ifp;
1303 struct hlist_node *node; 1303 struct hlist_node *node;
1304 unsigned int hash = ipv6_addr_hash(addr);
1305 1304
1306 hlist_for_each_entry(ifp, node, &inet6_addr_lst[hash], addr_lst) { 1305 hlist_for_each_entry(ifp, node, &inet6_addr_lst[hash], addr_lst) {
1307 if (!net_eq(dev_net(ifp->idev->dev), net)) 1306 if (!net_eq(dev_net(ifp->idev->dev), net))
1308 continue; 1307 continue;
1309 if (ipv6_addr_equal(&ifp->addr, addr)) { 1308 if (ipv6_addr_equal(&ifp->addr, addr)) {
1310 if (dev == NULL || ifp->idev->dev == dev) 1309 if (dev == NULL || ifp->idev->dev == dev)
1311 break; 1310 return true;
1312 } 1311 }
1313 } 1312 }
1314 return ifp != NULL; 1313 return false;
1315} 1314}
1316 1315
1317int ipv6_chk_prefix(struct in6_addr *addr, struct net_device *dev) 1316int ipv6_chk_prefix(struct in6_addr *addr, struct net_device *dev)