Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp1116053lqb; Wed, 17 Apr 2024 23:53:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXB7VlGlNomzpOikQ77bfm1bmWbBcV4HPuipd8MXUO9OgA+zssNfg9mL+X9UHOKDZgw1tohS9ANEtSR14DPhdxVyWhnYFy3pfhSZX1Hzw== X-Google-Smtp-Source: AGHT+IFApg5BHq7Jh5uxshWd5W4fMM79iuiCDjAXhbcMYDxFxfshE8b02t27B+gPZ2A6FHX2ncH2 X-Received: by 2002:a17:906:1b10:b0:a52:571c:3d7b with SMTP id o16-20020a1709061b1000b00a52571c3d7bmr1017104ejg.59.1713423204071; Wed, 17 Apr 2024 23:53:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713423204; cv=pass; d=google.com; s=arc-20160816; b=KjRxLbtvZ2T8hM9q7HEXMkSF9ganTRpYbtrw6o3Balg/NyN3jyXRScyi9PsTyaDCtH kqymVMhEc9mynHlJ+syIOJQk9ztaTZtqcdLK+4qKOonW90Lai+oFd8rQFVdduh0tFrBv RYA5MhpBVFk2iYoO1Xg6CFEA6IEAbaZ8SF/bkIdF9BfADMnnHwB12v6Rs1ztlVBvWsHQ h0pxCMgG5+fzy3EyIZUjNcac1LxuizSheN6xC77IBCdI6L58qiT6dV8G6zK3Fl5obTgt gxmYW+yqhzoAraKXcmJgqsWDOCSnsu9S7dQXyLGgPgn9Q+n9479ggtcv2fIK3J8A1v/x ow6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qC0zbqS3FQ+Zn4xV4lRWFo3BO0VRfJLwRrQ9QuGIorY=; fh=YYtFaTh6jmUHOX3piBwKVhvKahvZzHkDNkn1TgANS8Q=; b=Ri1Z5HBPHynHLii6fwo+qhI8MWkmd6JSwi/pyS6b/8Wj1XiIl3mgGSKDYNYEZuf9Z3 pFRQTUqG21P6uIp7w2frYuTlOvodabteh9nd42tX9yYL1gZ//R14RCjF3vLdZVcVcdGZ bUvQsskGUq/OZ6eBPqV038znT/R0vJbyyY4zEpCjketW1nr4kwXsdGy1k9pYcaEhx9sw oUeeCz/cZ9a8qfn3z5abiUdW8PgL5x9N8HWLgkA/4Q3xa39ctrIyG0evkl2+m1UWI2qc gNauNyZ7rWgftsYxQQ5S2Lr3T/xl8ShUWZ0ltBXKUWg7MuzctAJ23REssKcNRDwO4T88 yShw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HXomSYYh; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-149621-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149621-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d20-20020a170906345400b00a522962dfecsi490499ejb.62.2024.04.17.23.53.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 23:53:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149621-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HXomSYYh; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-149621-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149621-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 am.mirrors.kernel.org (Postfix) with ESMTPS id A04951F21924 for ; Thu, 18 Apr 2024 06:53:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DE5437719; Thu, 18 Apr 2024 06:53:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="HXomSYYh" Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B4902C6BB for ; Thu, 18 Apr 2024 06:53:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713423195; cv=none; b=ISfWD2cn1LLrdibSzBlLSrJWf6TFf0FThN5+f1bUwXSRXgty+EQMP/sD5JiugysZ1UyTMNThKzWy7rsTE0wzjIF4iTyoAsElzKamJIuBFQ7qs86ie2dVJ0QvoNh+m3sKY/sw0JS7lW7ucjbl3wnGrYYcH07sWGX4gKqiuyAp/P8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713423195; c=relaxed/simple; bh=pl0E0/CPNvyU7tX7pTfKZh9cVPJsQcytPBidCAR/NJE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=E7WZHj07GGVDBBIlJeQDl0lIY5UdK5wSFLABfrTDbZVOf3/Nl22blzsrFYM9btHeaLU7SKhuVtusjRP6c/Zl7eUaiiVy3XdUS1bPT0KQdQduASs6/hNw28Y2kQ0vqPCAwyecgSImuDv+Wm/Hf2Ozn0/tKX3InDCYIy8u8LarHBo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=HXomSYYh; arc=none smtp.client-ip=209.85.215.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-5e42b4bbfa4so298318a12.1 for ; Wed, 17 Apr 2024 23:53:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713423192; x=1714027992; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=qC0zbqS3FQ+Zn4xV4lRWFo3BO0VRfJLwRrQ9QuGIorY=; b=HXomSYYhKH6YcsukxcbuyFVExmZbki9R/E9JdlcJPVWF75621Bua/owT40IYgrNOVT LTkXTyg17UVy6EpOku2KyTUqqQ8bucS16wogHMAOV92RR5K5ZRYk8pmgbcogGlL2bpVh VMiBIUk39Z2JWzGXnTA9f6SoCHotHC4Fm73dzK3xbK/5v5UwzrXnA7MgWGTfEiYIcwnv 9JZvSbUlQSrdntKJv5LXTuM0KQ3NO8O+xlMR8nfGxhnQwDk7Z5q1sZXh5DexATu26W82 CioYaSoNpf3H/OeyNR1lLKQ6/I1bV3yRpaJ5joHeUBXQN3v7BBpr9oxL1Mhr/S6JPOwz 4I7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713423192; x=1714027992; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qC0zbqS3FQ+Zn4xV4lRWFo3BO0VRfJLwRrQ9QuGIorY=; b=pf4G1oLkTmAms6oVjMtvbYemJPLEUwPwDOEPujxZ8IYprV6p7E+egLHu+qj4TScfwm ujeCwlbyX56kevEEFC1zet4otsSF6SqgV6wPtkHyLDSWOLqfOmmUFM3J89ee90hTTiWU lUW2nUMcJ2/5cigPz+6rurwelJet3DgY9TrCs+wgaFc75i7G1feNe7OsaEz9sxsNcUMj DyAr0IWecPvgXpXC69m8itImO2n7OfheGAZ9tGd70Kr5tuoboGpv4sVSyj9cTQcZxk1i aPGgqGXwqCJyHi+KlFinLGMysLSNCQX6RhnUkaCMqtidOfbu1YrITDBNF3GLeohaqaP/ +fUQ== X-Forwarded-Encrypted: i=1; AJvYcCUkD9sfope51vVHYf6vidgGju0wxjIL9SPy1jHV+sx13jgrlNVg4Aw1COGqOR66KBzqfImeQtCoR4tCmBU0vGogyf0AfED52Knid/mV X-Gm-Message-State: AOJu0Yy9hiOSZHI5Q0CmKy21r7v2v6FeajKexQKVTcK9vAplBLYSe1zP QhuzMWeEz3X84046+xzhw9SiYE9XGpzFHSg+2V8KrA9InpofDPWyXXm4D3aWsQ== X-Received: by 2002:a05:6a21:1f27:b0:1aa:5d76:1916 with SMTP id ry39-20020a056a211f2700b001aa5d761916mr2203144pzb.34.1713423192398; Wed, 17 Apr 2024 23:53:12 -0700 (PDT) Received: from thinkpad ([120.56.197.253]) by smtp.gmail.com with ESMTPSA id fj32-20020a056a003a2000b006eac4297ed3sm766902pfb.20.2024.04.17.23.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 23:53:11 -0700 (PDT) Date: Thu, 18 Apr 2024 12:23:08 +0530 From: Manivannan Sadhasivam To: Niklas Cassel Cc: Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Dan Carpenter Subject: Re: [PATCH] PCI: endpoint: pci-epf-test: Make use of cached 'epc_features' in pci_epf_test_core_init() Message-ID: <20240418065308.GG2861@thinkpad> References: <20240417-pci-epf-test-fix-v1-1-653c911d1faa@linaro.org> <20240418054319.GB2861@thinkpad> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, Apr 18, 2024 at 08:46:47AM +0200, Niklas Cassel wrote: > On Thu, Apr 18, 2024 at 11:13:19AM +0530, Manivannan Sadhasivam wrote: > > On Wed, Apr 17, 2024 at 07:49:45PM +0200, Niklas Cassel wrote: > > > On Wed, Apr 17, 2024 at 10:47:25PM +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. This also leads to the following 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) > > > > > > > > Reported-by: Dan Carpenter > > > > Closes: https://lore.kernel.org/linux-pci/024b5826-7180-4076-ae08-57d2584cca3f@moroto.mountain/ > > > > Signed-off-by: Manivannan Sadhasivam > > > > > > I think you forgot: > > > Fixes: a01e7214bef9 ("PCI: endpoint: Remove "core_init_notifier" flag") > > > > > > > No, that's not the correct fixes tag I suppose. This redudant check is > > introduced by commit, 5e50ee27d4a5 ("PCI: pci-epf-test: Add support to defer > > core initialization") and this commit removes the redundant check (fixing smatch > > warning is a side effect). So if the fixes tag needs to be added, then this > > commit should be referenced. > > Well, you have a Closes: tag that links to a bug report about a smatch > warning that was introduced with 5e50ee27d4a5 ("PCI: pci-epf-test: Add > support to defer core initialization"). > > So if you want to reference another commit, then you should probably > drop the Closes: tag. > Then checkpatch will complain... But I think I can keep the two tags? One is for fixing the redudant check and another is for the smatch warning reported. > > > > > > [...] > > > That way, we assign msi_capable/msix_capable just before the if-statement > > > where it is used. (Which matches how we already assign msix_capable just > > > before the if-statement in pci_epf_test_alloc_space().) > > > > > > > Ok, if we go with this pattern, then pci_epf_test_set_bar() also needs to be > > updated. > > pci_epf_test_set_bar() ? I presume that you mean pci_epf_test_alloc_space(). > Oops. I referred from an old branch. > How about a 1/2 patch that modifies pci_epf_test_core_init() and Closes: the > bug report, and a 2/2 patch that modifies pci_epf_test_alloc_space() ? > Yes, that's the plan. - Mani -- மணிவண்ணன் சதாசிவம்