Re: [PATCH v3 3/3] cxl/core: use cleanup.h for devm_cxl_add_dax_region

From: Gregory Price

Date: Fri Feb 20 2026 - 00:24:10 EST


On Tue, Feb 17, 2026 at 04:55:13PM -0700, Dave Jiang wrote:
>
>
> On 2/11/26 1:42 PM, Gregory Price wrote:
> > Cleanup the gotos in the function.
> >
> > No functional change intended.
> >
> > Signed-off-by: Gregory Price <gourry@xxxxxxxxxx>
> > ---
> > drivers/cxl/core/region_dax.c | 21 ++++++++-------------
> > drivers/cxl/cxl.h | 1 +
> > 2 files changed, 9 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/cxl/core/region_dax.c b/drivers/cxl/core/region_dax.c
> > index c8dd2bd1d9b9..49907c6c7620 100644
> > --- a/drivers/cxl/core/region_dax.c
> > +++ b/drivers/cxl/core/region_dax.c
> > @@ -81,29 +81,24 @@ static void cxlr_dax_unregister(void *_cxlr_dax)
> >
> > int devm_cxl_add_dax_region(struct cxl_region *cxlr)
> > {
> > - struct cxl_dax_region *cxlr_dax;
> > - struct device *dev;
> > + struct cxl_dax_region *cxlr_dax __free(put_cxl_dax_region) = NULL;
> > int rc;
> >
> > cxlr_dax = cxl_dax_region_alloc(cxlr);
>
> The typical __cleanup() pattern is to move the variable declaration here in order to minimize unintended issues between declare and check.
>

Ah, relatively new pattern for me, i'll clean it up

> > if (IS_ERR(cxlr_dax))
> > return PTR_ERR(cxlr_dax);
> >
> > - dev = &cxlr_dax->dev;
>
> Given that this local var is used multiple times, maybe we should keep it?
>

Fair, will re-spin claned up

~Gregory