Re: [PATCH 23/28] mfd: ab8500-core: Register sysfs attribute groups via devm_device_add_group()

From: Linus Walleij

Date: Wed Oct 21 2026 - 19:41:21 EST


Hi Lee,

On Wed, Oct 21, 2026 at 2:16 PM Lee Jones <lee@xxxxxxxxxx> wrote:

> ab8500_probe() registers up to two sysfs attribute groups with
> sysfs_create_group(). On AB8505 and AB9540 (cut 2.0 and later), the
> second sysfs_create_group() call unconditionally overwrites the return
> value of the first, and if the second call fails, ab8500_probe() returns
> an error without removing the first group. Because the driver context
> is freed and driver data is cleared on probe failure, reading any leaked
> sysfs attribute dereferences a NULL ab8500 pointer in
> get_register_interruptible().
>
> Register the attribute groups via devm_device_add_group() and only
> register the second group when the first succeeds so that devres
> automatically cleans up registered sysfs attributes on probe failure.
>
> Fixes: 93ff722e8853 ("ab8500-fg: Add power cut feature for ab8505 and ab8540")
> Closes: https://sashiko.dev/#/bug/linux-a9ac1a9d-5a97-4ad3-b4c5-c7775c24a333
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>

Neat, thanks for fixing!
Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>

Yours,
Linus Walleij