Re: [PATCH v3] cxl: Check for invalid addresses returned from translation functions on errors

From: Robert Richter

Date: Tue Jan 13 2026 - 12:45:22 EST


On 13.01.26 08:51:15, Dave Jiang wrote:
>
>
> On 1/7/26 5:05 AM, Robert Richter wrote:
> > Translation functions may return an invalid address in case of errors.
> > If the address is not checked the further use of the invalid value
> > will cause an address corruption.
> >
> > Consistently check for a valid address returned by translation
> > functions. Use RESOURCE_SIZE_MAX to indicate an invalid address for
> > type resource_size_t. Depending on the type either RESOURCE_SIZE_MAX
> > or ULLONG_MAX is used to indicate an address error.
> >
> > Reviewed-by: Dave Jiang <dave.jiang@xxxxxxxxx>
> > Signed-off-by: Robert Richter <rrichter@xxxxxxx>
> > ---
> > v3:
> > * updated sob-chain,
> > * changed error handling flow in test/cxl_translate.c (Alison),
> >
> > v2:
> > * separated from this patch series (Alison):
> > [PATCH v8 00/13] cxl: ACPI PRM Address Translation Support and AMD Zen5 enablement
> > * improved error handling logic and early return on error in
> > region_offset_to_dpa_result() (Dave),
> > * use RESOURCE_SIZE_MAX to indicate an invalid address for
> > resource_size_t types (Alison, kernel test robot),
> > * improved patch description (Alison),
> > * added line wrap for code >80 chars.
> > ---
> >
> > Signed-off-by: Robert Richter <rrichter@xxxxxxx>
>
> Applied to cxl/fixes
> 8441c7d3bd6c5a52ab2ecf77e43a5bf262004f5c

Thanks Alison and Dave.

> Added user impact statement and fixed up tab formatting reported by checkpatch.

> > + pr_err("test random iter %d FAIL hpa=%llu, dpa=%llu reverse_dpa=%llu, pos=%d reverse_pos=%d eiw=%u eig=%u\n",
> > + i, hpa, dpa, reverse_dpa, pos, reverse_pos, eiw, eig);

Note that my checkpatch does not trigger a tab issue here. How did you
test that?

Thanks,

-Robert