Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1714821

[net-next PATCH] ipv6: fix false-postive maybe-uninitialized warning

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject [net-next PATCH] ipv6: fix false-postive maybe-uninitialized warning
Date 2017-08-18 13:40 +0200
Message-ID <ufNN8-346-21@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Adding a lock around one of the assignments prevents gcc from
tracking the state of the local 'fibmatch' variable, so it can no
longer prove that 'dst' is always initialized, leading to a bogus
warning:

net/ipv6/route.c: In function 'inet6_rtm_getroute':
net/ipv6/route.c:3659:2: error: 'dst' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This moves the other assignment into the same lock to shut up the
warning.

Fixes: 121622dba8da ("ipv6: route: make rtm_getroute not assume rtnl is locked")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 net/ipv6/route.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

This kind of warning involving an unlock between variable initialization
and use is relatively frequent for false-positives. I should try to
seek clarification from the gcc developers on whether this can be
improved.

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index dc021ed6dd37..bec12ae3e6b7 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3624,6 +3624,8 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
 
 		if (!fibmatch)
 			dst = ip6_route_input_lookup(net, dev, &fl6, flags);
+		else
+			dst = ip6_route_lookup(net, &fl6, 0);
 
 		rcu_read_unlock();
 	} else {
@@ -3631,10 +3633,10 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
 
 		if (!fibmatch)
 			dst = ip6_route_output(net, NULL, &fl6);
+		else
+			dst = ip6_route_lookup(net, &fl6, 0);
 	}
 
-	if (fibmatch)
-		dst = ip6_route_lookup(net, &fl6, 0);
 
 	rt = container_of(dst, struct rt6_info, dst);
 	if (rt->dst.error) {
-- 
2.9.0

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[net-next PATCH] ipv6: fix false-postive maybe-uninitialized warning Arnd Bergmann <arnd@arndb.de> - 2017-08-18 13:40 +0200
  Re: [net-next PATCH] ipv6: fix false-postive maybe-uninitialized  warning David Miller <davem@davemloft.net> - 2017-08-18 19:50 +0200
    Re: [net-next PATCH] ipv6: fix false-postive maybe-uninitialized warning Arnd Bergmann <arnd@arndb.de> - 2017-08-18 21:50 +0200

csiph-web