Re: [PATCH v2 5/7] cxl/core: Use guard() to drop goto pattern of cxl_dpa_alloc()

From: Dan Williams
Date: Wed Feb 19 2025 - 20:30:08 EST


Li Ming wrote:
[..]
> After __cxl_dpa_alloc(), a 'devm_add_action_or_reset(&port->dev,
> cxl_dpa_release, cxled)' will be invoked, cxl_dpa_rwsem is possible to
> be held in cxl_dpa_release() in devm_add_action_or_reset() failure
> case.
>
> So I create __cxl_dpa_alloc() to hold cxl_dpa_rwsem for the operations
> needed cxl_dpa_resem protection, make sure that the cxl_dpa_rwsem is
> released before devm_add_action_or_reset() invoking.

Ah, got it, missing context, makes sense.