Re: [PATCH v2] counter: Fix refcount leak in counter_alloc() error path

From: William Breathitt Gray

Date: Sun May 03 2026 - 00:55:29 EST



On Mon, 13 Apr 2026 21:46:04 +0800, Guangshuo Li wrote:
> After device_initialize(), the lifetime of the embedded struct device
> is expected to be managed through the device core reference counting.
>
> In counter_alloc(), if dev_set_name() fails after device_initialize(),
> the error path removes the chrdev, frees the ID, and frees the backing
> allocation directly instead of releasing the device reference with
> put_device(). This bypasses the normal device lifetime rules and may
> leave the reference count of the embedded struct device unbalanced,
> resulting in a refcount leak.
>
> [...]

Applied, thanks!

[1/1] counter: Fix refcount leak in counter_alloc() error path
commit: d9eeb0ea0d2de658663bfaa9c26eccdd8fd64440

Best regards,
--
William Breathitt Gray <wbg@xxxxxxxxxx>