Message ID | 20230616090844.2677815-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1195169vqr; Fri, 16 Jun 2023 02:25:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4QbiFfvUUejhT5FHl6z2QUq358uFcPyzkiqQuRdngf5sKl3KsJupLlTSMKrcBoKQRNN+fs X-Received: by 2002:a05:6a00:189a:b0:64a:5cde:3a7d with SMTP id x26-20020a056a00189a00b0064a5cde3a7dmr1721418pfh.27.1686907527098; Fri, 16 Jun 2023 02:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907527; cv=none; d=google.com; s=arc-20160816; b=CbgtOlT/3GrMg9sAjtH/4sEPlXxfPtuzH8OCBs6pn3rVw33tS2o89xxJpndGKGkN/t oYjzQX3x9WkArTA9LjussyoCOJktIWZ436mY8XpK7iYnl2ltDaDQhff7pPqWnN+yMdNJ Nb1qgzBNLVEklHG/1Wgwj9BQ/XNm+DMOGkRdW9Q3XTDMFJYQJmQK0mhqhg31EWtVw+8V gmtweTOAd4Tku//H+zvhs871wEMH6gCm+z56yheBg8m283aI6Bs+k5aUYlggWFz2z406 EGdJSwu2mj6O3Wb/QDumzlJLYii3l1RFZvO4gvmFelCgAwEa5OM6TSD0jcMrQQcCFKOF Vifg== 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:dkim-signature; bh=hKR6hQjksmR0KBzz+tuMD71ZVi6IBuAamKpBSDUnXGQ=; b=xrSFCapWhuUYWareOVC9Ce2tCsnIMUrRfL46jwuYT8zthlQ9EaYHjvB1WAlVXCvG8K C5NtET9/Sp549r3QETltNzmVSyhIO5voRXtZJW1oniWafE9ZesZj7sNf0o9DVoDaqiNA A+xvNRRnlAwQJpo8v4uTi7TJSzv5EpZiV3oD+mVkos+VhetYWXx6CMLsu/J7nB7IU62s Zjz8rAkyiIXC1IgAonMPd/5Q++kwc0TFIAU3CdIUaljMQgaR0SZJph7QbKC5nXGoSmHO s6aO7v2yqig/HRrcJ9EUmCwrylgd6tuIJPPfvzki02wMZO34jyvDzCkVpX5g4qwFPsAy COvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XkA67CHY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e29-20020a056a0000dd00b006434e20d023si11305260pfj.399.2023.06.16.02.25.10; Fri, 16 Jun 2023 02:25:27 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XkA67CHY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243398AbjFPJKk (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Fri, 16 Jun 2023 05:10:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344507AbjFPJKK (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 16 Jun 2023 05:10:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 577DA3AB3 for <linux-kernel@vger.kernel.org>; Fri, 16 Jun 2023 02:08:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7166F6326F for <linux-kernel@vger.kernel.org>; Fri, 16 Jun 2023 09:08:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17B15C433C0; Fri, 16 Jun 2023 09:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686906530; bh=6H2J61C/zhonIL9tyV87l0liBvz4B9aaRzMD1YpvQE4=; h=From:To:Cc:Subject:Date:From; b=XkA67CHY1l+/tBfiCQacrRszQ1FP6oXVHm5ALNsIXr8juvZASfoEOzpZltWLv1qVa MAgvEtQkesLYwgMy/4gDfqYvp/gcie/gDWHkSvfm1w+86ecyiiEpt/kFLplu1vTlv7 5x4oie6b2M3sir6hIzR18fRZrFrJMOWJ7ZAK8/hlg+zE11g/JzOHOBQj3JrWzhMaVJ qFh2Jl7MHO7Sa8BUiK4mdKIIhBesmn890oA0PSesNnWPeQ68ncgqt2lAx+hPxEikZj q3e3hZzQhtfeW/ux3bsO5cYPL/5oLX5mcqHt1bt5V3hQY3h8zkkvcB8h1JgtMwR5Ol 9CmN1N/q/O6+A== From: Arnd Bergmann <arnd@kernel.org> To: Edward Cree <ecree.xilinx@gmail.com>, Martin Habets <habetsm.xilinx@gmail.com>, Jakub Kicinski <kuba@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <simon.horman@corigine.com>, Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@amd.com>, netdev@vger.kernel.org, linux-net-drivers@amd.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] sfc: fix uninitialized variable use Date: Fri, 16 Jun 2023 11:08:18 +0200 Message-Id: <20230616090844.2677815-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768850747114780308?= X-GMAIL-MSGID: =?utf-8?q?1768850747114780308?= |
Series |
[1/2] sfc: fix uninitialized variable use
|
|
Commit Message
Arnd Bergmann
June 16, 2023, 9:08 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de> The new efx_bind_neigh() function contains a broken code path when IPV6 is disabled: drivers/net/ethernet/sfc/tc_encap_actions.c:144:7: error: variable 'n' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (encap->type & EFX_ENCAP_FLAG_IPV6) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/sfc/tc_encap_actions.c:184:8: note: uninitialized use occurs here if (!n) { ^ drivers/net/ethernet/sfc/tc_encap_actions.c:144:3: note: remove the 'if' if its condition is always false if (encap->type & EFX_ENCAP_FLAG_IPV6) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/sfc/tc_encap_actions.c:141:22: note: initialize the variable 'n' to silence this warning struct neighbour *n; ^ = NULL Change it to use the existing error handling path here. Fixes: 7e5e7d800011a ("sfc: neighbour lookup for TC encap action offload") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/net/ethernet/sfc/tc_encap_actions.c | 1 + 1 file changed, 1 insertion(+)
Comments
On Fri, Jun 16, 2023 at 11:08:18AM +0200, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > The new efx_bind_neigh() function contains a broken code path when IPV6 is > disabled: > > drivers/net/ethernet/sfc/tc_encap_actions.c:144:7: error: variable 'n' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] > if (encap->type & EFX_ENCAP_FLAG_IPV6) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/net/ethernet/sfc/tc_encap_actions.c:184:8: note: uninitialized use occurs here > if (!n) { > ^ > drivers/net/ethernet/sfc/tc_encap_actions.c:144:3: note: remove the 'if' if its condition is always false > if (encap->type & EFX_ENCAP_FLAG_IPV6) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/net/ethernet/sfc/tc_encap_actions.c:141:22: note: initialize the variable 'n' to silence this warning > struct neighbour *n; > ^ > = NULL > > Change it to use the existing error handling path here. > > Fixes: 7e5e7d800011a ("sfc: neighbour lookup for TC encap action offload") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Simon Horman <simon.horman@corigine.com>
On 16/06/2023 10:08, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > The new efx_bind_neigh() function contains a broken code path when IPV6 is > disabled: > > drivers/net/ethernet/sfc/tc_encap_actions.c:144:7: error: variable 'n' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] > if (encap->type & EFX_ENCAP_FLAG_IPV6) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/net/ethernet/sfc/tc_encap_actions.c:184:8: note: uninitialized use occurs here > if (!n) { > ^ > drivers/net/ethernet/sfc/tc_encap_actions.c:144:3: note: remove the 'if' if its condition is always false > if (encap->type & EFX_ENCAP_FLAG_IPV6) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/net/ethernet/sfc/tc_encap_actions.c:141:22: note: initialize the variable 'n' to silence this warning > struct neighbour *n; > ^ > = NULL > > Change it to use the existing error handling path here. > > Fixes: 7e5e7d800011a ("sfc: neighbour lookup for TC encap action offload") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > drivers/net/ethernet/sfc/tc_encap_actions.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/ethernet/sfc/tc_encap_actions.c b/drivers/net/ethernet/sfc/tc_encap_actions.c > index aac259528e73e..cfd76d5bbdd48 100644 > --- a/drivers/net/ethernet/sfc/tc_encap_actions.c > +++ b/drivers/net/ethernet/sfc/tc_encap_actions.c > @@ -163,6 +163,7 @@ static int efx_bind_neigh(struct efx_nic *efx, > * enabled how did someone create an IPv6 tunnel_key? > */ > rc = -EOPNOTSUPP; > + n = NULL; > NL_SET_ERR_MSG_MOD(extack, "No IPv6 support (neigh bind)"); > #endif > } else { > Nack. There is a bug here, as you've identified, but the right fix is to add a 'goto out_free;' after setting the rc and extack msg. Setting n to NULL and relying on the subsequent error path will not only produce the wrong rc and error message, it will also attempt to drop a reference on neigh->egdev that was never taken. -ed
diff --git a/drivers/net/ethernet/sfc/tc_encap_actions.c b/drivers/net/ethernet/sfc/tc_encap_actions.c index aac259528e73e..cfd76d5bbdd48 100644 --- a/drivers/net/ethernet/sfc/tc_encap_actions.c +++ b/drivers/net/ethernet/sfc/tc_encap_actions.c @@ -163,6 +163,7 @@ static int efx_bind_neigh(struct efx_nic *efx, * enabled how did someone create an IPv6 tunnel_key? */ rc = -EOPNOTSUPP; + n = NULL; NL_SET_ERR_MSG_MOD(extack, "No IPv6 support (neigh bind)"); #endif } else {