dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Esben Haabendal" <esben@geanix.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 2/3] drm/bridge: ti-sn65dsi83: Fix error handling in sn65dsi83_reset_work()
Date: Mon, 03 Aug 2026 15:21:11 +0000	[thread overview]
Message-ID: <20260803152112.5CC281F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803-ti-sn65dsi83-fixes-v3-2-9b403a405ccd@geanix.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [Critical] Missing cancel_work_sync() for ctx->reset_work during driver teardown leads to a Use-After-Free.
- [High] Skipping enable_irq() on the error path causes an IRQ disable depth leak, leaving the interrupt permanently disabled.
--

--- Patch [2]: [PATCH v3 2/3] drm/bridge: ti-sn65dsi83: Fix error handling in sn65dsi83_reset_work() ---
commit 58246b5ef131d7aeea7b5c2b693088e7255aa435
Author: Esben Haabendal <esben@geanix.com>

drm/bridge: ti-sn65dsi83: Fix error handling in sn65dsi83_reset_work()

This commit fixes the error path in sn65dsi83_reset_work() by adding a
goto to ensure drm_bridge_exit() is called when sn65dsi83_reset_pipe()
fails, safely closing the critical section.

> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> @@ -419,11 +419,12 @@ static void sn65dsi83_reset_work(struct work_struct *ws)

[Severity: Critical]
This is a pre-existing issue, but could this work function execute after
the device is unbound, resulting in a use-after-free?

If the driver is removed and devres frees the ctx structure, the work
could still be pending since sn65dsi83_remove() does not appear to call
cancel_work_sync() before returning:

sn65dsi83_remove() {
        ...
        drm_bridge_unplug(&ctx->bridge);
        // missing cancel_work_sync(&ctx->reset_work);
}

If the workqueue executes sn65dsi83_reset_work() after teardown,
dereferencing ctx for drm_bridge_enter() might access freed memory.

>  	ret = sn65dsi83_reset_pipe(ctx);
>  	if (ret) {
>  		dev_err(ctx->dev, "reset pipe failed %pe\n", ERR_PTR(ret));
> -		return;
> +		goto err_exit;

[Severity: High]
This isn't a bug introduced by this patch, but doesn't jumping to err_exit
here leave the interrupt permanently disabled?

If a hardware error triggers the IRQ handler, sn65dsi83_handle_errors()
calls disable_irq_nosync(), which increments the IRQ disable depth. By
skipping the enable_irq() call on this error path, the depth counter
remains unbalanced.

Would it be better to mask the interrupt source via hardware registers
on failure, and still call enable_irq() so the kernel's depth counter
remains balanced?

>  	}
>  	if (ctx->irq)
>  		enable_irq(ctx->irq);
>  
> +err_exit:
>  	drm_bridge_exit(idx);
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260803-ti-sn65dsi83-fixes-v3-0-9b403a405ccd@geanix.com?part=2

  reply	other threads:[~2026-08-03 15:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 14:57 [PATCH v3 0/3] drm/bridge: ti-sn65dsi83: Various fixes Esben Haabendal
2026-08-03 14:57 ` [PATCH v3 1/3] drm/bridge: ti-sn65dsi83: Propagate error in sn65dsi83_reset_pipe() Esben Haabendal
2026-08-03 15:04   ` sashiko-bot
2026-08-04  6:41     ` Esben Haabendal
2026-08-05  7:46   ` Luca Ceresoli
2026-08-05  7:56     ` Esben Haabendal
2026-08-03 14:57 ` [PATCH v3 2/3] drm/bridge: ti-sn65dsi83: Fix error handling in sn65dsi83_reset_work() Esben Haabendal
2026-08-03 15:21   ` sashiko-bot [this message]
2026-08-04  6:48     ` Esben Haabendal
2026-08-03 14:57 ` [PATCH v3 3/3] drm/bridge: ti-sn65dsi83: Support LVDS Channel B on SN65DSI84 Esben Haabendal
2026-08-06  9:02 ` [PATCH v3 0/3] drm/bridge: ti-sn65dsi83: Various fixes Luca Ceresoli
2026-08-06  9:20   ` Esben Haabendal

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=20260803152112.5CC281F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=esben@geanix.com \
    --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