From mboxrd@z Thu Jan 1 00:00:00 1970 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 91468EB64D7 for ; Fri, 16 Jun 2023 11:29:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235252AbjFPL32 (ORCPT ); Fri, 16 Jun 2023 07:29:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235200AbjFPL30 (ORCPT ); Fri, 16 Jun 2023 07:29:26 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FB602130; Fri, 16 Jun 2023 04:29:24 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-30c55d2b9f3so389259f8f.2; Fri, 16 Jun 2023 04:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686914963; x=1689506963; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject:from:to:cc :subject:date:message-id:reply-to; bh=ZQYl/X7cVGReKQi5TZlRt9DYXVaMgcFNStYfbfHB4wo=; b=PAE35ImSBw40YhqoVA4tYR8BrFDnWzfowMD4fVGXnhCdBKoNoN/76o2dMxWMbzEjxK 2Cq6CmEmZe2ie4/+QzNo8zbfL7fTYilVXLEP2mGi4waAO6AZXhN8/fmYVyTErdjBayLT PaHhp2K5pM+H1dDmloOcio9Gn/swU3RFTu87wzF8ydwVz2frqrHysKeVSk7aaEW7aYnp K5QTAithGF3NiUw4tzTQme703vnzrSbDvXL558IZkmIyp296TUg9zNprzwfpHSEBM+2T JS1mEMnKce6Vjl6wfOaWCcx1UZ20FOsjE5ArLtaHzVy6Tfui37dgvaZ9pE6dFQZMK+Z3 B7vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686914963; x=1689506963; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZQYl/X7cVGReKQi5TZlRt9DYXVaMgcFNStYfbfHB4wo=; b=JfNR1djV6kybozNFi6bb1A9F947Q3FVF6HHqlOogXEUasccxhg9kKNoiZTErZQweNk OCrQ+CIMCd81wEPJku7dgGRvK9pibdrGKb2HyKVmw8w5adUuqWyGE/l6NyHcREbd3xFd em+BNRCd3L8k1lsDoMKNHXC1gvveqtTh5LCmVQeUKykEmBem3p+ymCZup+GQOw0RWgfP R5NTkt38pWBQzReR45yzR5bXHo0hLruzPDAHHl6BxYBAG6SgOBN+oE22oSOSV8nt6rF5 KVzoDaaBTY4LvJM3wZDG1PRfegnCou/d6WMma7NpwkGOEbchRlOXCZMK4FTsYBVzoE3n 6lRw== X-Gm-Message-State: AC+VfDwH1rKXefDR0TmXCmaYvlNp/mzYciYxVOOSrfigXLGWvDYurn3h EncVrKuXd92pQ3n0K1Gfie8969DUbCU= X-Google-Smtp-Source: ACHHUZ5vIInpoRudDeijycYLzQsH+fgdl2bAO5KX5gFXk1Xgs1slBF2/QhAbcvFg/iKXciYVC9IVug== X-Received: by 2002:a5d:660f:0:b0:311:e41:d71d with SMTP id n15-20020a5d660f000000b003110e41d71dmr1098747wru.28.1686914962810; Fri, 16 Jun 2023 04:29:22 -0700 (PDT) Received: from [192.168.1.122] (cpc159313-cmbg20-2-0-cust161.5-4.cable.virginm.net. [82.0.78.162]) by smtp.gmail.com with ESMTPSA id n16-20020adfe350000000b0030e5b1fffc3sm23470853wrj.9.2023.06.16.04.29.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Jun 2023 04:29:22 -0700 (PDT) Subject: Re: [PATCH 1/2] sfc: fix uninitialized variable use To: Arnd Bergmann , Martin Habets , Jakub Kicinski Cc: Arnd Bergmann , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Pieter Jansen van Vuuren , netdev@vger.kernel.org, linux-net-drivers@amd.com, linux-kernel@vger.kernel.org References: <20230616090844.2677815-1-arnd@kernel.org> From: Edward Cree Message-ID: Date: Fri, 16 Jun 2023 12:29:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20230616090844.2677815-1-arnd@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/06/2023 10:08, Arnd Bergmann wrote: > From: Arnd Bergmann > > 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 > --- > 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