Re: [PATCH 1/6] ASoC: wm8962: Fix regulator notifier and beep leaks on card re-bind
From: Charles Keepax
Date: Mon Sep 14 2026 - 06:57:00 EST
On Sun, Sep 13, 2026 at 07:15:26PM +0900, Chancel Liu wrote:
> From: Chancel Liu <chancel.liu@xxxxxxx>
>
> wm8962 registers its regulator disable notifiers and allocates its beep
> input device from the ASoC component probe, but the associated devres
> cleanup is tied to the underlying I2C device.
>
> These resources are only leaked when the sound card is unregistered and
> re-registered while the I2C device stays bound. On that path the
> component probe runs again and:
>
> - re-registers the same notifier_block on the still-registered
> regulator notifier chain, which triggers
>
> notifier callback wm8962_regulator_event_N already registered
> WARNING: ... at kernel/notifier.c:23 notifier_chain_register
>
> and corrupts the chain.
>
> - allocates and registers a new beep input device every time while
> wm8962_free_beep() only clears the pointer, leaking the previous
> input device and its sysfs/input node.
>
> Fix both:
> - Move the regulator notifier registration to wm8962_i2c_probe() so it
> runs once per I2C device bind.
>
> - Allocate the beep device with input_allocate_device() and pair it
> with the component lifecycle: input_free_device() on registration
> failure and input_unregister_device() in wm8962_free_beep().
>
> Signed-off-by: Chancel Liu <chancel.liu@xxxxxxx>
> ---
Reviewed-by: Charles Keepax <ckeepax@xxxxxxxxxxxxxxxxxxxxx>
Thanks,
Charles