Re: [PATCH v4 6/6] cxl/region: Reject poison scan for decoder without a partition

[email protected]
Newsgroups org.kernel.vger.linux-cxl
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Returning `-ENODEV` for an unmapped partition aborts the entire poison collection iteration.
--

--- Patch [6]: [PATCH v4 6/6] cxl/region: Reject poison scan for decoder without a partition ---
commit 8cb40391df3fd49e0cd36f0f034423d0470da73b
Author: Richard Cheng <[email protected]>

cxl/region: Reject poison scan for decoder without a partition

__cxl_dpa_reserve() may leave cxled->part at -1 when a decoder's DPA
range doesn't map to any reported partition, while still keeping
dpa_res. This commit returns -ENODEV before accessing the partition array
when no partition was assigned to avoid an out-of-bounds read.

> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index b7dc5d4988da7..afe3fb57b7fe2 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -2954,6 +2954,8 @@ static int poison_by_decoder(struct device *dev, void *arg)
>  	cxled = to_cxl_endpoint_decoder(dev);
>  	if (!cxled->dpa_res)
>  		return rc;
> +	if (cxled->part < 0)
> +		return -ENODEV;

[Severity: Medium]
Since poison_by_decoder() is used as an iterator callback for
device_for_each_child(), does returning -ENODEV here prematurely abort the
entire poison collection iteration?

If any decoder on the port has an unmapped partition, returning a negative
error code would halt the traversal. The sysfs trigger would then fail with
-ENODEV, skipping poison collection for all subsequent decoders.

Would it be better to return 0 here to just skip the unmapped decoder and
continue iterating over the remaining ones?

>  
>  	cxlmd = cxled_to_memdev(cxled);
>  	cxlds = cxlmd->cxlds;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.