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

From: Robert Richter

Date: Wed Jan 07 2026 - 07:03:13 EST


On 06.01.26 10:42:36, Alison Schofield wrote:
> On Tue, Jan 06, 2026 at 06:23:58PM +0100, Robert Richter wrote:

> > @@ -3207,8 +3220,13 @@ static int region_offset_to_dpa_result(struct cxl_region *cxlr, u64 offset,
> > cxled = p->targets[i];
> > if (cxled->pos != pos)
> > continue;
> > +
> > + dpa = cxl_dpa_resource_start(cxled);
>
> We want to return -ENXIO, not 0 in this case.
> So jump out here immediately - right?
>
> if (dpa == REsOURCE_SIZE_MAX)
> return -ENXIO;

The users of region_offset_to_dpa_result() handle the
RESOURCE_SIZE_MAX case. For that reason the dpa is not checked here.
I did not want to change the function interface with that fix.

Thanks for review.

-Robert

>
>
> > + if (dpa != RESOURCE_SIZE_MAX)
> > + dpa += dpa_offset;
> > +
> > result->cxlmd = cxled_to_memdev(cxled);
> > - result->dpa = cxl_dpa_resource_start(cxled) + dpa_offset;
> > + result->dpa = dpa;
> >
> > return 0;
> > }