Skip to content

Commit 55e2686

Browse files
YanfeiXudavejiang
authored andcommitted
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: 560f785 ("cxl/pci: Retrieve CXL DVSEC memory info") Reviewed-by: Jonathan Cameron <[email protected]> Signed-off-by: Yanfei Xu <[email protected]> Reviewed-by: Alison Schofield <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Dave Jiang <[email protected]>
1 parent d75ccd4 commit 55e2686

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

drivers/cxl/core/pci.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,6 @@ int cxl_dvsec_rr_decode(struct device *dev, int d,
390390

391391
size |= temp & CXL_DVSEC_MEM_SIZE_LOW_MASK;
392392
if (!size) {
393-
info->dvsec_range[i] = (struct range) {
394-
.start = 0,
395-
.end = CXL_RESOURCE_NONE,
396-
};
397393
continue;
398394
}
399395

@@ -411,12 +407,10 @@ int cxl_dvsec_rr_decode(struct device *dev, int d,
411407

412408
base |= temp & CXL_DVSEC_MEM_BASE_LOW_MASK;
413409

414-
info->dvsec_range[i] = (struct range) {
410+
info->dvsec_range[ranges++] = (struct range) {
415411
.start = base,
416412
.end = base + size - 1
417413
};
418-
419-
ranges++;
420414
}
421415

422416
info->ranges = ranges;

0 commit comments

Comments
 (0)