From: Alison Schofield <alison.schofield@intel.com>
To: Li Ming <ming.li@zohomail.com>
Cc: kobayashi.da-06@fujitsu.com, dave@stgolabs.net,
jonathan.cameron@huawei.com, dave.jiang@intel.com,
vishal.l.verma@intel.com, ira.weiny@intel.com,
dan.j.williams@intel.com, linux-cxl@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] cxl/pci: Check dport->regs.rcd_pcie_cap availability before accessing
Date: Thu, 5 Dec 2024 10:19:46 -0800 [thread overview]
Message-ID: <Z1HuwuKf7CYu-7K8@aschofie-mobl2.lan> (raw)
In-Reply-To: <20241129132825.569237-1-ming.li@zohomail.com>
On Fri, Nov 29, 2024 at 09:28:25PM +0800, Li Ming wrote:
> RCD Upstream Port's PCI Express Capability is a component registers
> block stored in RCD Upstream Port RCRB. CXL PCI driver helps to map it
> during the RCD probing, but mapping failure is allowed for component
> registers blocks in CXL PCI driver.
>
> dport->regs.rcd_pcie_cap is used to store the virtual address of the RCD
> Upstream Port's PCI Express Capability, add a dport->regs.rcd_pcie_cap
> checking in rcd_pcie_cap_emit() just in case user accesses a invalid
> address via RCD sysfs.
I traced this enough to convince myself that dport cannot be NULL if
cxl_mem_find_port() succeeds. So, LGTM -
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
>
> Fixes: c5eaec79fa43 ("cxl/pci: Add sysfs attribute for CXL 1.1 device link status")
> Signed-off-by: Li Ming <ming.li@zohomail.com>
> ---
> drivers/cxl/pci.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index b2cb81f6d9e7..e53b1c95a248 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -836,6 +836,9 @@ static ssize_t rcd_pcie_cap_emit(struct device *dev, u16 offset, char *buf, size
> if (!root_dev)
> return -ENXIO;
>
> + if (!dport->regs.rcd_pcie_cap)
> + return -ENXIO;
> +
> guard(device)(root_dev);
> if (!root_dev->driver)
> return -ENXIO;
> --
> 2.34.1
>
next prev parent reply other threads:[~2024-12-05 18:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-29 13:28 [PATCH 1/1] cxl/pci: Check dport->regs.rcd_pcie_cap availability before accessing Li Ming
2024-12-05 18:19 ` Alison Schofield [this message]
2024-12-09 23:44 ` Dan Williams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z1HuwuKf7CYu-7K8@aschofie-mobl2.lan \
--to=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=jonathan.cameron@huawei.com \
--cc=kobayashi.da-06@fujitsu.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.li@zohomail.com \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox