Re: [PATCH 1/6] cxl/mem: Fix devm_cxl_memdev_edac_release() confusion
From: Cheatham, Benjamin
Date: Thu Dec 04 2025 - 14:09:33 EST
On 12/3/2025 8:21 PM, Dan Williams wrote:
> A device release method is only for undoing allocations on the path to
> preparing the device for device_add(). In contrast, devm allocations are
> post device_add(), are acquired during / after ->probe() and are released
> synchronous with ->remove().
>
> So, a "devm" helper in a "release" method is a clear anti-pattern.
>
> Move this devm release action where it belongs, an action created at edac
> object creation time. Otherwise, this leaks resources until
> cxl_memdev_release() time which may be long after these xarray and error
> record caches have gone idle.
>
> Note, this also fixes up the type of @cxlmd->err_rec_array which needlessly
> dropped type-safety.
>
> Fixes: 0b5ccb0de1e2 ("cxl/edac: Support for finding memory operation attributes from the current boot")
> Cc: Dave Jiang <dave.jiang@xxxxxxxxx>
> Cc: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> Cc: Shiju Jose <shiju.jose@xxxxxxxxxx>
> Cc: Alison Schofield <alison.schofield@xxxxxxxxx>
> Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
> ---
Reviewed-by: Ben Cheatham <benjamin.cheatham@xxxxxxx>