Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	mfd@lists.linux.dev, robh@kernel.org, conor+dt@kernel.org,
	lee@kernel.org
Subject: Re: [PATCH 1/9] backlight: qcom-wled: fix unbalanced OVP interrupt enable
Date: Thu, 15 Oct 2026 09:22:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-172565@kernel.org> (raw)
In-Reply-To: <20261015-sm8150-display-card-v1-1-5c14928cef29@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] backlight: ABBA deadlock between wled->lock and ovp_irq handler
- [High] backlight: missing cancel_delayed_work_sync in wled_probe() error path
--

commit f07dcfad88603020539ad65ef60f36337093bf41
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

    backlight: qcom-wled: fix unbalanced OVP interrupt enable
    
    If the bootloader leaves the WLED module enabled, the OVP interrupt is
    left enabled at probe time. The first brightness update then schedules
    wled_ovp_work(), which enables the interrupt for a second time and
    triggers the "Unbalanced enable for IRQ" warning.
    
    Track whether the driver has disabled the interrupt and only enable it
    back in that case.
    
    Fixes: 8663c188beea ("backlight: qcom-wled: Add auto string detection logic")
    Assisted-by: LLM
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

> diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
> index 650dd95f06ef5..f2e0430cccbca 100644
> --- a/drivers/video/backlight/qcom-wled.c
> +++ b/drivers/video/backlight/qcom-wled.c
[ ... ]
> @@ -321,8 +326,11 @@ static int wled_module_enable(struct wled *wled, int val)
>  			 */
>  			schedule_delayed_work(&wled->ovp_work, HZ / 100);

[Severity: High]
Could this delayed work execution lead to a use-after-free if probe fails?

In wled_probe(), INIT_DELAYED_WORK(&wled->ovp_work, wled_ovp_work) initializes
the delayed work without registering a devm action for cancellation.
wled_probe() then requests the short IRQ, making it active.

If a short IRQ triggers during probe, its handler calls wled_module_enable()
which reaches here and globally schedules ovp_work.

If wled_probe() subsequently returns an error (e.g., if
devm_backlight_device_register() fails), devres automatically frees the wled
structure without cancelling the scheduled work. When ovp_work executes, won't
it dereference the freed wled structure?

>  		} else {
> -			if (!cancel_delayed_work_sync(&wled->ovp_work))
> +			cancel_delayed_work_sync(&wled->ovp_work);
> +			if (!wled->ovp_irq_disabled) {
>  				disable_irq(wled->ovp_irq);

[Severity: High]
Does this code introduce an ABBA deadlock with the OVP IRQ handler?

If wled_update_status() or wled_short_irq_handler() disables the module, it
holds wled->lock and calls wled_module_enable(wled, false), which reaches here
and blocks in disable_irq() waiting for any currently executing OVP IRQ handler
to complete.

Meanwhile, the threaded OVP IRQ handler tries to acquire wled->lock to perform
auto string detection:

drivers/video/backlight/qcom-wled.c:wled_ovp_irq_handler() {
    ...
	if (fault_sts & WLED3_CTRL_REG_OVP_FAULT_BIT) {
		if (wled->wled_auto_detection_required(wled)) {
			mutex_lock(&wled->lock);
			wled_auto_string_detection(wled);
			mutex_unlock(&wled->lock);
		}
	}
    ...
}

If the OVP IRQ fires concurrently, will disable_irq() wait forever while the
handler waits for wled->lock?

> +				wled->ovp_irq_disabled = true;
> +			}
>  		}
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015-sm8150-display-card-v1-0-5c14928cef29@oss.qualcomm.com?part=1

  parent reply	other threads:[~2026-10-15  9:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  8:58 [PATCH 0/9] arm64: qcom: enable display card support on SM8150 HDK Dmitry Baryshkov
2026-10-15  8:58 ` [PATCH 1/9] backlight: qcom-wled: fix unbalanced OVP interrupt enable Dmitry Baryshkov
2026-10-15  9:11   ` Konrad Dybcio
2026-10-15  9:44     ` Dmitry Baryshkov
2026-10-15  9:22   ` sashiko-bot [this message]
2026-10-15  8:58 ` [PATCH 2/9] backlight: qcom-wled: fix string detection brightness on WLED5 Dmitry Baryshkov
2026-10-15  9:13   ` Konrad Dybcio
2026-10-15  9:17   ` sashiko-bot
2026-10-15  8:58 ` [PATCH 3/9] dt-bindings: regulator: add Qualcomm LCDB regulator Dmitry Baryshkov
2026-10-15  9:14   ` Konrad Dybcio
2026-10-15  8:58 ` [PATCH 4/9] dt-bindings: mfd: qcom,spmi-pmic: add LCDB Dmitry Baryshkov
2026-10-15  8:58 ` [PATCH 5/9] regulator: add Qualcomm LCDB driver Dmitry Baryshkov
2026-10-15  9:31   ` sashiko-bot
2026-10-15  8:58 ` [PATCH 6/9] arm64: dts: qcom: pm8150l: add LCDB regulators Dmitry Baryshkov
2026-10-15  9:39   ` sashiko-bot
2026-10-15  8:58 ` [PATCH 7/9] arm64: dts: qcom: sm8150: add MDSS reset Dmitry Baryshkov
2026-10-15  9:15   ` Konrad Dybcio
2026-10-15  8:58 ` [PATCH 8/9] arm64: dts: qcom: sm8150-hdk: fix FSA4480 address Dmitry Baryshkov
2026-10-15  9:10   ` Konrad Dybcio
2026-10-15  9:11     ` Konrad Dybcio
2026-10-15  8:58 ` [PATCH 9/9] arm64: dts: qcom: sm8150-hdk: add display card overlay Dmitry Baryshkov

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=sashiko-outbox-172565@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lee@kernel.org \
    --cc=mfd@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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