Re: [PATCH 4/6] backlight: qcom-wled: Manage teardown via devres and remove wled_remove()
From: Konrad Dybcio
Date: Thu Nov 05 2026 - 03:15:13 EST
On 11/4/26 7:39 PM, Lee Jones wrote:
> wled_remove() currently runs before devres tears down the backlight
> device and threaded interrupts, resulting in two teardown bugs:
>
> 1. mutex_destroy(&wled->lock) and cancel_delayed_work_sync(&wled->ovp_work)
> execute while the backlight device registered via
> devm_backlight_device_register() and the short interrupt requested
> via devm_request_threaded_irq() are still active. A concurrent sysfs
> brightness update or short interrupt during unbind can acquire the
> destroyed mutex and re-schedule wled->ovp_work before devres frees
> the wled structure.
>
> 2. disable_irq(wled->short_irq) and disable_irq(wled->ovp_irq) are
> called unconditionally even when the optional "short" or "ovp"
> interrupts are absent from the Device Tree (-ENXIO) or unused (0 on
> WLED3), passing invalid IRQ numbers to disable_irq(), despite both
> interrupts already being managed by devm_request_threaded_irq().
>
> Initialise wled->lock with devm_mutex_init() and remove wled_remove()
> so that devres tears down the backlight device, short interrupt,
> delayed work, OVP interrupt, mutex, and driver data in reverse
> registration order.
>
> Fixes: feeab87b3072 ("backlight: qcom-wled: Add support for short circuit handling")
> Fixes: 8663c188beea ("backlight: qcom-wled: Add auto string detection logic")
> Closes: https://sashiko.dev/#/bug/linux-51cd5e35-3cae-4e4c-986b-7261263507cd
> Closes: https://sashiko.dev/#/bug/linux-44e5ed80-c35c-4786-8bf8-9ee955967d0b
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>
Konrad