Re: [PATCH 1/2] cxl/region: fix region leak when attach_target fails in cxl_add_to_region
From: Gregory Price
Date: Sat Feb 21 2026 - 00:17:56 EST
On Fri, Feb 20, 2026 at 11:30:12PM -0500, Gregory Price wrote:
> cxl_add_to_region() ignores the return value of attach_target(). When
> attach_target() fails (e.g. cxl_port_setup_targets() returns -ENXIO),
> the auto-discovered region remains registered with its HPA resource
> consumed but never reaches COMMIT state. Subsequent region creation
> attempts fail with -ENOSPC because the HPA range is already reserved.
>
> Track whether this call to cxl_add_to_region() created the region, and
> call drop_region() on attach_target() failure to unregister it and
> release the HPA resource. Pre-existing regions are left alone since
> other endpoints may already be attached.
>
> Signed-off-by: Gregory Price <gourry@xxxxxxxxxx>
BAH - disregard this patch, it uses drop_region which is introduced by
Alejandro here:
https://lore.kernel.org/linux-cxl/20260201155438.2664640-20-alejandro.lucero-palau@xxxxxxx/