Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp1156194lqb; Thu, 18 Apr 2024 01:31:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXxFiIOS5ieDYb70IAcIGTJt5+8gyuGCk8Pg5ilUpN2FlrSBdqRyMdyXjxOF45K4zmGit9X3ZGapNvaOhol5Cy8phIVosZnYnQ//lYoUw== X-Google-Smtp-Source: AGHT+IH69Ojm3WMc3giE0ylLgbDUD28GvGtJkL5SaU4bN3qUJs5fN/QldLFGMCSD3sY/m3QEe5wk X-Received: by 2002:a17:902:d2d0:b0:1e5:9dee:9f34 with SMTP id n16-20020a170902d2d000b001e59dee9f34mr2426167plc.36.1713429095084; Thu, 18 Apr 2024 01:31:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713429095; cv=pass; d=google.com; s=arc-20160816; b=l3/RP4xBilHggQknbxu0bE7MHsvNpyhsidLzxWRMW8EwNYBDoFC2FxCHrz54k5ZLyw pZwYONtlOAmITI1cQAnfbGI9pSfxtjCHMYqKaGUe4r3n0Gp3A/r6a4l6UFGJhCKro8y8 WhOsUOVQRdzzgxMTy6Ci9OO4ghJe4TkuanoeVySPZ7ap1SGX1/tHu6TtuCAN/xpS2NFr Pqtf4Q7zKqEvKylzB8XLeRFhMzLPLyCQw3+ectP/m9UsX6Hnlwa2IsTBYXtYRPqv0yf3 HBoFs7ZSXjjKzIsVGVE4VJ3IqJGn7npN2gF6LxcCPqzp6ALUdsHA3LFFSjJKfbFQqozO AzGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=toNLzyKZ1EQiTY3tZcdv0FoHZC0Jnx3FJB7JTtBlhzI=; fh=DLYtOguL9xGCnb9QRdwIfd4xbunjsQgd6cgubCg/tMU=; b=p8pCL7/f3RL6jurhHY+LJvV3Q9px8b4AwPeCZYirCTBRCi3xutn1DBuE5Df2US2Kpk VyDNuMXBR2YSNHnA9u/J5GigMrYfF+Ql+q8ZJPrubJlSzIDpbCJquGlKAR9wGIY64QEH DGoBRQtapVN+IHcVXWl1S4vRgj82KdsyMa+LLQoxkWExGbwMyUz7uRtK9otIEYmN8wFn PU6ok0uq++pdl6kY2XIpPyO6eDBOmP4qKuAf7dpPmC0IcASQb0tuYT0WPn07nbzQrr+k ode5KB6BzPJx1ALuKfq0/pKQerKLMoDjh2AHDdjFRuiK+bYe08wBHsllyIww8r5oCFS+ W0TA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mgYX6Is9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-149721-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149721-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p23-20020a1709028a9700b001e503e6dbb4si957181plo.167.2024.04.18.01.31.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 01:31:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149721-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mgYX6Is9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-149721-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149721-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B1523B22142 for ; Thu, 18 Apr 2024 08:31:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B8F5140E40; Thu, 18 Apr 2024 08:29:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mgYX6Is9" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A445513B5BE; Thu, 18 Apr 2024 08:29:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713428965; cv=none; b=sdzTixo3jquiZQcqX/Rexpn9YADIbR4jGNqzKcC9ANqFr5xQEW2r7t3oAojYUoSzhIcRqoYOnLC9eQvox1g1sAQ+iP8dLhlfl4diB+ZbZ6GwBlNsP9IflXvydgUAU8q7C604oCveqO7YB/2c7frrRRIgNgl1NqADGFgTHdBqPEU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713428965; c=relaxed/simple; bh=bd8KmP0eNG6QIoiOj3QS9njH5HAgdTcy6xAd31jpY+s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TceBjW89x+4FLoEKDtmFutuufl3PiIDZLJ6CgIuMNyX+ZJ4fdAepXKV3xaGOQdbH5PT083qZKXTYPUkXaJUopJpgH9ykJDWD3ATicTcwZD9Wi/AQ/etIp3Y6TknJhip6YIHx3DUg7kCf97QDOWY2STvLK0IVqEEAF2PbqFHUcRQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mgYX6Is9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E293C116B1; Thu, 18 Apr 2024 08:29:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713428965; bh=bd8KmP0eNG6QIoiOj3QS9njH5HAgdTcy6xAd31jpY+s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mgYX6Is9pnYyLfqN4t6HRm206VvNEyftvmE/q+ffdHdAkNqCghhQoHBZoNK2b7QnF THpFxKwWANBSMogYGsYR6gQ9Be1Iaxts+b72UxcszVF/76/SDY/AdLNz8mlXupnIDs Nf7/g4yu5z/7A7EpGgfrDwuEzgozlFF91uHD2cddhrQA+U4Wgf80IyWiiPn4TkwyqK 64aJkLcJhCx5/P5jtTLwHgBp+OG7hZYFbD3qbHnw/U7dde8hLwMNfJSMg2mvY3UOt2 IYSbtqcoLk6ze/k9UMO5oergEZWz0LW/V8MGn677ECQh51FaetghK+r1ERnHKI8BWy MJGFpsMw7i0Dg== Date: Thu, 18 Apr 2024 10:29:20 +0200 From: Niklas Cassel To: Manivannan Sadhasivam Cc: Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Lorenzo Pieralisi , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Dan Carpenter Subject: Re: [PATCH v2 1/2] PCI: endpoint: pci-epf-test: Make use of cached 'epc_features' in pci_epf_test_core_init() Message-ID: References: <20240418-pci-epf-test-fix-v2-0-eacd54831444@linaro.org> <20240418-pci-epf-test-fix-v2-1-eacd54831444@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240418-pci-epf-test-fix-v2-1-eacd54831444@linaro.org> On Thu, Apr 18, 2024 at 01:29:58PM +0530, Manivannan Sadhasivam wrote: > Instead of getting the epc_features from pci_epc_get_features() API, use > the cached pci_epf_test::epc_features value to avoid the NULL check. Since > the NULL check is already performed in pci_epf_test_bind(), having one more > check in pci_epf_test_core_init() is redundant and it is not possible to > hit the NULL pointer dereference. > > Also with commit a01e7214bef9 ("PCI: endpoint: Remove "core_init_notifier" > flag"), 'epc_features' got dereferenced without the NULL check, leading to > the following false positive smatch warning: > > drivers/pci/endpoint/functions/pci-epf-test.c:784 pci_epf_test_core_init() > error: we previously assumed 'epc_features' could be null (see line 747) > > So let's remove the redundant NULL check and also use the epc_features:: > {msix_capable/msi_capable} flags directly to avoid local variables. > > Reported-by: Dan Carpenter > Closes: https://lore.kernel.org/linux-pci/024b5826-7180-4076-ae08-57d2584cca3f@moroto.mountain/ > Fixes: 5e50ee27d4a5 ("PCI: pci-epf-test: Add support to defer core initialization") > Signed-off-by: Manivannan Sadhasivam > --- Reviewed-by: Niklas Cassel