From patchwork Fri Aug 18 11:34:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 110382 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp789157qge; Fri, 18 Aug 2017 04:35:05 -0700 (PDT) X-Received: by 10.84.215.210 with SMTP id g18mr9488641plj.210.1503056105859; Fri, 18 Aug 2017 04:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503056105; cv=none; d=google.com; s=arc-20160816; b=z4qxKORZy5jnizij3+jqu8z3CjQJcvfFsaeZQcfJ1haif1g75706p6B7114BjnB4xN 9WXeLx1dWCVyXGwkg2lDgqjQbBENPj7zxO6TXfqhKkdcCnlwQ8O42+On4Hj10nv40/Gk WPROicpq7NEfnbO8QCw/qA9t6jW10iAZdnAEI4fdLxmbu+t4E0cdnUp61cbX7/PTYYbq u/ETTEJOzTzmEVYH5raFkHdOPThZAcxKn9Cs3GGHMw5bNR38x26FOVhjZHGD82XlCoQn 1miEufl8yjoLDuygjyY3InR4yuU8Vn5RB8YcQHnnwcFbctxV5b+JWu8XaXAJkrg2bfcX tAOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=uFLG5BS6iStqDHZTg18BUqpH8jstfz72ABp7P5i0rYQ=; b=UDKHNFvyqD+RGZlCPystOIT2dMD2u3dVZP3zPn70ahsL9uuemj3286iuw0NQKpelrx yZSDRMpqwxsCD83+h+msv6xMWnbzRj1fMj0tguqYqxQAgLMwVM0IuHO3YXJjQRhintRX DRJ5uWmbm2QLRQBcqTg43pMUuB1mryXg7gj6DdsJDh+FUETF5K0bdKsK994XNgqqgkdj KD+X1zgzgkthTsPeKCwUExbcM+dgr7NQsNcyZut4EJtp9ekQ1ZdGzmtn2acA8+sllow7 vBBt0D8tW8YiFjGzTFKp8v/b2iQPNhm6yZAj3TNopSJN4NDWkLwjomRE95VgKprBg3BH dx+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 92si3762219pli.551.2017.08.18.04.35.05; Fri, 18 Aug 2017 04:35:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751695AbdHRLfD (ORCPT + 26 others); Fri, 18 Aug 2017 07:35:03 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:52222 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750709AbdHRLfB (ORCPT ); Fri, 18 Aug 2017 07:35:01 -0400 Received: from wuerfel.lan ([95.208.155.18]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MB6xw-1dqPKA46bs-00A13M; Fri, 18 Aug 2017 13:34:43 +0200 From: Arnd Bergmann To: "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI Cc: Florian Westphal , Arnd Bergmann , David Ahern , Martin KaFai Lau , Wei Wang , WANG Cong , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH] ipv6: fix false-postive maybe-uninitialized warning Date: Fri, 18 Aug 2017 13:34:22 +0200 Message-Id: <20170818113434.3037484-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:YeT7EOwNQNGSd5X0jf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-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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. -- 2.9.0 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) {