From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Daniel Thompson <danielt@kernel.org>,
Jingoo Han <jingoohan1@gmail.com>, Helge Deller <deller@gmx.de>,
Bjorn Andersson <andersson@kernel.org>,
Kiran Gunda <quic_kgunda@quicinc.com>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org, David Heidelberg <david@ixit.cz>,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Subject: [PATCH 4/6] backlight: qcom-wled: Manage teardown via devres and remove wled_remove()
Date: Wed, 4 Nov 2026 18:39:05 +0000 [thread overview]
Message-ID: <20261104183935.1214630-5-lee@kernel.org> (raw)
In-Reply-To: <20261104183935.1214630-1-lee@kernel.org>
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@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
Cc: David Heidelberg <david@ixit.cz>
Cc: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
drivers/video/backlight/qcom-wled.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
index f8f41e1d6ccf..8d4d7fe5e84d 100644
--- a/drivers/video/backlight/qcom-wled.c
+++ b/drivers/video/backlight/qcom-wled.c
@@ -1732,7 +1732,6 @@ static int wled_probe(struct platform_device *pdev)
wled->regmap = regmap;
wled->dev = &pdev->dev;
- platform_set_drvdata(pdev, wled);
wled->version = (uintptr_t)of_device_get_match_data(&pdev->dev);
if (!wled->version) {
@@ -1740,7 +1739,10 @@ static int wled_probe(struct platform_device *pdev)
return -ENODEV;
}
- mutex_init(&wled->lock);
+ rc = devm_mutex_init(&pdev->dev, &wled->lock);
+ if (rc)
+ return rc;
+
rc = wled_configure(wled);
if (rc)
return rc;
@@ -1822,16 +1824,6 @@ static int wled_probe(struct platform_device *pdev)
return PTR_ERR_OR_ZERO(bl);
};
-static void wled_remove(struct platform_device *pdev)
-{
- struct wled *wled = platform_get_drvdata(pdev);
-
- mutex_destroy(&wled->lock);
- cancel_delayed_work_sync(&wled->ovp_work);
- disable_irq(wled->short_irq);
- disable_irq(wled->ovp_irq);
-}
-
static const struct of_device_id wled_match_table[] = {
{ .compatible = "qcom,pm8941-wled", .data = (void *)3 },
{ .compatible = "qcom,pmi8950-wled", .data = (void *)4 },
@@ -1846,7 +1838,6 @@ MODULE_DEVICE_TABLE(of, wled_match_table);
static struct platform_driver wled_driver = {
.probe = wled_probe,
- .remove = wled_remove,
.driver = {
.name = "qcom,wled",
.of_match_table = wled_match_table,
--
2.56.0.385.gac671c819a-goog
next prev parent reply other threads:[~2026-11-04 18:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 18:39 [PATCH 0/6] backlight: Fix Critical and High issues reported by Sashiko Lee Jones
2026-11-04 18:39 ` [PATCH 1/6] backlight: lm3630a: Request PWM device before registering backlight Lee Jones
2026-11-04 18:39 ` [PATCH 2/6] backlight: aat2870: Initialise driver data " Lee Jones
2026-11-04 18:39 ` [PATCH 3/6] backlight: qcom-wled: Cancel delayed work on probe failure Lee Jones
2026-11-04 18:39 ` Lee Jones [this message]
2026-11-04 18:39 ` [PATCH 5/6] backlight: qcom-wled: Check for auto-detection callback in wled_ovp_irq_handler() Lee Jones
2026-11-04 18:39 ` [PATCH 6/6] backlight: qcom-wled: Avoid AB-BA deadlock in wled_module_enable() Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261104183935.1214630-5-lee@kernel.org \
--to=lee@kernel.org \
--cc=andersson@kernel.org \
--cc=danielt@kernel.org \
--cc=david@ixit.cz \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=jingoohan1@gmail.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_kgunda@quicinc.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox