Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cxl/pci: Fix to record only non-zero ranges

The function cxl_dvsec_rr_decode() retrieves and records DVSEC ranges
into info->dvsec_range[], regardless of whether it is non-zero range,
and the variable info->ranges indicates the number of non-zero ranges.
However, in cxl_hdm_decode_init(), the validation for
info->dvsec_range[] occurs in a for loop that iterates based on
info->ranges. It may result in zero range to be validated but non-zero
range not be validated, in turn, the number of allowed ranges is to be
0. Address it by only record non-zero ranges.

This fix is not urgent as it requires a configuration that zeroes out
the first dvsec range while populating the second. This has not been
observed, but it is theoretically possible. If this gets picked up for
-stable, no harm done, but there is no urgency to backport.

Fixes: 560f78559006 ("cxl/pci: Retrieve CXL DVSEC memory info")
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Yanfei Xu <yanfei.xu@intel.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Link: https://patch.msgid.link/20240828084231.1378789-2-yanfei.xu@intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>

authored by

Yanfei Xu and committed by
Dave Jiang
55e26869 d75ccd4f

+1 -7
+1 -7
drivers/cxl/core/pci.c
··· 390 390 391 391 size |= temp & CXL_DVSEC_MEM_SIZE_LOW_MASK; 392 392 if (!size) { 393 - info->dvsec_range[i] = (struct range) { 394 - .start = 0, 395 - .end = CXL_RESOURCE_NONE, 396 - }; 397 393 continue; 398 394 } 399 395 ··· 407 411 408 412 base |= temp & CXL_DVSEC_MEM_BASE_LOW_MASK; 409 413 410 - info->dvsec_range[i] = (struct range) { 414 + info->dvsec_range[ranges++] = (struct range) { 411 415 .start = base, 412 416 .end = base + size - 1 413 417 }; 414 - 415 - ranges++; 416 418 } 417 419 418 420 info->ranges = ranges;