All of 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 v4 2/3] drm/bridge: ti-sn65dsi83: Propagate error in sn65dsi83_reset_pipe()
Date: Mon, 10 Aug 2026 07:36:04 +0000	[thread overview]
Message-ID: <20260810073604.BD1A51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260810-ti-sn65dsi83-fixes-v4-2-ae9c95c8d162@geanix.com>

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

Pre-existing issues:
- [High] The background work `reset_work` is not cancelled when the device is unbound, leading to a Use-After-Free when the workqueue executes the pending work item after the driver data structure has been freed.
- [High] Re-enabling the interrupt after a failed bridge reset creates an interrupt storm and infinite workqueue loop.
- [High] Preexisting double-unlock of connection_mutex in drm_bridge_helper_reset_crtc() triggered during pipeline reset.
--

--- Patch [2]: [PATCH v4 2/3] drm/bridge: ti-sn65dsi83: Propagate error in sn65dsi83_reset_pipe() ---
commit a871b12bfaa133da03afd275986f3c4abe9be9c0
Author: Esben Haabendal <esben@geanix.com>
drm/bridge: ti-sn65dsi83: Propagate error in sn65dsi83_reset_pipe()

This commit modifies sn65dsi83_reset_pipe() to propagate the error code from
drm_bridge_helper_reset_crtc() instead of unconditionally returning 0. This
gives callers the opportunity to handle reset failures.

> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> index 0ccfff401b2a6..475224c5a5d83 100644
> --- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
> @@ -403,7 +403,7 @@ static int sn65dsi83_reset_pipe(struct sn65dsi83 *sn65dsi83)
>  	drm_modeset_drop_locks(&ctx);
>  	drm_modeset_acquire_fini(&ctx);
>  
> -	return 0;
> +	return err;

[Severity: High]
This is a pre-existing issue, but returning the error here exposes a
problem in drm_bridge_helper_reset_crtc() which is called earlier in
this function.

Does drm_bridge_helper_reset_crtc() suffer from a double-unlock of
connection_mutex?

It manually acquires connection_mutex, then calls:
drm_atomic_get_connector_for_encoder(encoder, ctx)

This helper appears to unconditionally unlock connection_mutex before returning:

drivers/gpu/drm/drm_atomic.c:drm_atomic_get_connector_for_encoder() {
    ...
    ret = drm_modeset_lock(&dev->mode_config.connection_mutex, ctx);
    ...
    drm_modeset_unlock(&dev->mode_config.connection_mutex);
    return out_connector;
}

Then drm_bridge_helper_reset_crtc() explicitly drops it again:

drivers/gpu/drm/drm_bridge_helper.c:drm_bridge_helper_reset_crtc() {
    ...
    connector = drm_atomic_get_connector_for_encoder(encoder, ctx);
    ...
out:
    drm_modeset_unlock(&dev->mode_config.connection_mutex);
    return ret;
}

Could this lead to lock state corruption or kernel panics when the reset path
is executed?

>  }
>  
>  static void sn65dsi83_reset_work(struct work_struct *ws)

[Severity: High]
This isn't a bug introduced by this patch, but now that
sn65dsi83_reset_pipe() propagates errors, will this workqueue re-enable the
interrupt even if the reset failed?

If sn65dsi83_reset_pipe() returns an error, the hardware might not be reset
and the error condition could remain asserted. If we unconditionally call
enable_irq(ctx->irq) at the end of sn65dsi83_reset_work():

drivers/gpu/drm/bridge/ti-sn65dsi83.c:sn65dsi83_reset_work() {
    ...
    ret = sn65dsi83_reset_pipe(ctx);
    if (ret)
        dev_err(ctx->dev, "reset pipe failed %pe\n", ERR_PTR(ret));

    if (ctx->irq)
        enable_irq(ctx->irq);
}

Will the interrupt immediately fire again, causing an interrupt storm and an
infinite workqueue loop?

[Severity: High]
This is another pre-existing issue, but there appears to be a problem with
reset_work during driver removal.

Does sn65dsi83_remove() fail to cancel reset_work before the device is
unbound?

drivers/gpu/drm/bridge/ti-sn65dsi83.c:sn65dsi83_remove() {
    struct sn65dsi83 *ctx = i2c_get_clientdata(client);

    drm_bridge_unplug(&ctx->bridge);
}

If an error interrupt fires and schedules reset_work, and the driver is
unbound before the work executes, will devres free the sn65dsi83 structure
while the workqueue still holds a dangling pointer to it, leading to a
use-after-free?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260810-ti-sn65dsi83-fixes-v4-0-ae9c95c8d162@geanix.com?part=2

  reply	other threads:[~2026-08-10  7:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10  7:19 [PATCH v4 0/3] drm/bridge: ti-sn65dsi83: Various fixes Esben Haabendal
2026-08-10  7:19 ` [PATCH v4 1/3] drm/bridge: ti-sn65dsi83: Fix error handling in sn65dsi83_reset_work() Esben Haabendal
2026-08-10  7:29   ` sashiko-bot
2026-08-10  7:19 ` [PATCH v4 2/3] drm/bridge: ti-sn65dsi83: Propagate error in sn65dsi83_reset_pipe() Esben Haabendal
2026-08-10  7:36   ` sashiko-bot [this message]
2026-08-10  7:19 ` [PATCH v4 3/3] drm/bridge: ti-sn65dsi83: Support LVDS Channel B on SN65DSI84 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=20260810073604.BD1A51F000E9@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.