Re: [PATCH v3 0/2] cxl/region: Fix race conditions in cxl region unregistration.

Jonathan Cameron
2026-04-27T12:51:44Z

On Sun, 26 Apr 2026 23:20:07 -0400
Sungwoo Kim <iam@sung-woo.kim> wrote:

> This version mainly addresses Dave's comments and meaningful issues reported by Sashiko AI[1].
>
> Overview
> ========
> This patch series fixes race conditions in cxl region unregistration.
>
> devm_release_action() should be called once, otherwise, it warns about
> the second call. However, the current implementation has a race condition
> that allows multiple calls to devm_release_action(). The details are in
> each patch.
>
> To fix these, the first patch adds a new function that guarantees that
> devm_release_action() is called only once.
> Using this function, the second patch subsitutes the current use of
> devm_release_action() in cxl region with the new function.
>
> Change in v3
> ============
> Addressed Dave's comments:
> - Split and made this in a patch series.
> - Enhanced a commit log explaining why a workqueue is used in the first patch.
> - Added a context on how these issues were found and what impact was observed and how that effects a user in the second patch.
> Sashiko AI review fixes:
> - Fixed construct_region() as it also can race.
> - Used a driver's wq instead of system wq so unbinding can drain a work.
>
> [1] https://sashiko.dev/#/patchset/20260422045637.3048249-2-iam%40sung-woo.kim
>
> Earlier approach:
> v2: https://lore.kernel.org/linux-cxl/20260422045637.3048249-2-iam@sung-woo.kim/
> v1: https://lore.kernel.org/linux-cxl/20260308185958.2453707-2-iam@sung-woo.kim/

Looks fine to me - I'm not particular keen on delayed releasing as it
may end up with unordered tear down but I don't have a better idea.

Reviewed-by: Jonathan Cameron <jic23@kernel.org>

>
> Sungwoo Kim (2):
> cxl/region: serialize devm action removal via scheduled work
> cxl/region: Fix a race bug in delete_region_store()
>
> drivers/cxl/core/port.c | 6 +++++
> drivers/cxl/core/region.c | 47 ++++++++++++++++++++++++++++++++++-----
> drivers/cxl/cxl.h | 9 ++++++++
> 3 files changed, 57 insertions(+), 5 deletions(-)
>