Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2237038rwl; Thu, 13 Apr 2023 03:46:49 -0700 (PDT) X-Google-Smtp-Source: AKy350aqokPgMxVTQ4LFQ1diJtssfCTSfBlZycCsWaxo5Ey8FPT03eB4T2/mXDiFX0jc61ERTB2d X-Received: by 2002:a17:906:7b4a:b0:94a:549c:4731 with SMTP id n10-20020a1709067b4a00b0094a549c4731mr2023974ejo.57.1681382809647; Thu, 13 Apr 2023 03:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681382809; cv=none; d=google.com; s=arc-20160816; b=kZRblJE4KEuUDMNURq6pljvxm+w8lKvvBkSF/7ooqz5X658iohVKFZZZnuC8087rHb RP3UCZlamCvRbKZdclCyHufaGmy2d1nwrgwuaaiwBXZ+cCDbcm4TwZ6WPr6ZEucHrXZB wBo7zMif5AzSY2gaK9PIASipRim4LYT9bsej3/ppyGtO0fkrF0/Ga9AVbTLjJo0fUgom Cl2nshkds0qi9WdVDCSLSt48cyGb49lJ/7y8xulIt3tbZyNj/ipBOt1bkQoFuCK2dgDf Cf/uQxPPr1nV8TenY0qA/EosaE05AegoN65rNjgcXratSgODZggfRsyxCBim+6aZav/W vGcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=onWTqSOqwZ313sT3iNfBdW7jW8dbqHvNuzvMcm7w6rg=; b=NSt1Ija8LlO7xkzPcp3lBEIypRlvKU3XRx8lmewdSMjCoHF7T0NuJhYyegaanmANjD TcHlsA/hcpIoqSo6vUCKT0cXNdlJFdvK4R1cgClDw01qnCGx5cgWr4W7nbaUoYe2OZM7 FuETcv1hKFwgjnunnqJcOoJtn4zAw3zNLO9uJ4zJbj30iEmasd38dFn9gP0G5CE+jQgD Hrxkvz3a0tApwq2hsSofKTxTDliipouqt65ooSqyyRCLcMY+lzGCVb2G4/iOLwNsU3FX LYPkavT4Y3NRDMJYBshRU2TvAvCwDXgHyLS+JAoIa+zKn+1eNtkoVKZXm4+iU6HLpiNO HcjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fi16-20020a1709073ad000b0094e8a4cf24asi1532625ejc.323.2023.04.13.03.46.24; Thu, 13 Apr 2023 03:46:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbjDMKYw (ORCPT + 99 others); Thu, 13 Apr 2023 06:24:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbjDMKYr (ORCPT ); Thu, 13 Apr 2023 06:24:47 -0400 Received: from hust.edu.cn (mail.hust.edu.cn [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BE6D1FF3; Thu, 13 Apr 2023 03:24:45 -0700 (PDT) Received: from fb20229aa3ce.us-central1-c.c.codatalab-user-runtimes.internal (254.140.184.35.bc.googleusercontent.com [35.184.140.254]) (user=iccccc@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 33DAAt5J005165-33DAAt5K005165 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Thu, 13 Apr 2023 18:11:11 +0800 From: Haoyi Liu To: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: hust-os-kernel-patches@googlegroups.com, yalongz@hust.edu.cn, error27@gmail.com, Haoyi Liu , Dongliang Mu , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2] net/ipv6: silence 'passing zero to ERR_PTR()' warning Date: Thu, 13 Apr 2023 10:10:05 +0000 Message-Id: <20230413101005.7504-1-iccccc@hust.edu.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: iccccc@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Smatch complains that if xfrm_lookup() returns NULL then this does a weird thing with "err": net/ ipv6/ icmp.c:411 icmpv6_route_lookup() warn: passing zero to ERR_PTR() Merge conditional paths and remove unnecessary 'else'. No functional change. Signed-off-by: Haoyi Liu Reviewed-by: Dongliang Mu --- v1->v2: Remove unnecessary 'else'. The issue is found by static analysis, and the patch is remains untested. --- net/ipv6/icmp.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 1f53f2a74480..a12eef11c7ee 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -393,17 +393,12 @@ static struct dst_entry *icmpv6_route_lookup(struct net *net, goto relookup_failed; dst2 = xfrm_lookup(net, dst2, flowi6_to_flowi(&fl2), sk, XFRM_LOOKUP_ICMP); - if (!IS_ERR(dst2)) { - dst_release(dst); - dst = dst2; - } else { - err = PTR_ERR(dst2); - if (err == -EPERM) { - dst_release(dst); - return dst2; - } else - goto relookup_failed; - } + err = PTR_ERR_OR_ZERO(dst2); + if (err && err != -EPERM) + goto relookup_failed; + + dst_release(dst); + return dst2; /* returns success or ERR_PTR(-EPERM) */ relookup_failed: if (dst) -- 2.40.0