From nobody Sun Feb 8 08:54:05 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B92C5C77B6E for ; Thu, 13 Apr 2023 10:24:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230358AbjDMKYx (ORCPT ); Thu, 13 Apr 2023 06:24:53 -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: quoted-printable X-FEAS-AUTH-USER: iccccc@hust.edu.cn Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Jacob Keller --- 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 n= et *net, goto relookup_failed; =20 dst2 =3D xfrm_lookup(net, dst2, flowi6_to_flowi(&fl2), sk, XFRM_LOOKUP_IC= MP); - if (!IS_ERR(dst2)) { - dst_release(dst); - dst =3D dst2; - } else { - err =3D PTR_ERR(dst2); - if (err =3D=3D -EPERM) { - dst_release(dst); - return dst2; - } else - goto relookup_failed; - } + err =3D PTR_ERR_OR_ZERO(dst2); + if (err && err !=3D -EPERM) + goto relookup_failed; + + dst_release(dst); + return dst2; /* returns success or ERR_PTR(-EPERM) */ =20 relookup_failed: if (dst) --=20 2.40.0