All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Fan Wu" <fanwu01@zju.edu.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/bridge: anx78xx: fix potential use-after-free on device removal
Date: Thu, 20 Aug 2026 04:58:02 +0000	[thread overview]
Message-ID: <20260820045803.177941F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260820044746.3087-1-fanwu01@zju.edu.cn>

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

Pre-existing issues:
- [Critical] Connector lifetime mismatch causes use-after-free on driver unbind.
- [High] Missing anx78xx_poweroff() in driver remove path leaves regulators enabled.
- [High] The INTP interrupt handler may dereference a NULL `connector.dev` pointer if an interrupt occurs before the bridge is attached.
- [High] DRM bridge operations can access freed regmap, regulator, and GPIO resources if called after device removal.
- [Medium] Missing mutex locking in probe and bridge enable/disable paths causes race conditions with threaded interrupt handlers.
--

--- Patch [1]: [PATCH] drm/bridge: anx78xx: fix potential use-after-free on device removal ---
commit 5c75354b8bb8f58551e701235d2a45c7111239b5
Author: Fan Wu <fanwu01@zju.edu.cn>

drm/bridge: anx78xx: fix potential use-after-free on device removal

The commit fixes a potential use-after-free on device removal by freeing
devm-managed interrupts before unregistering dummy i2c clients. It also
adds a missing devm_free_irq() call in the probe error path.

Cc: stable@vger.kernel.org

> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> index 32186efa6f501..735b0404ceba8 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> @@ -1309,6 +1309,7 @@ static int anx78xx_i2c_probe(struct i2c_client *client)
>  					"anx78xx-intp", anx78xx);
>  	if (err) {
>  		DRM_ERROR("Failed to request INTP threaded IRQ: %d\n", err);
> +		devm_free_irq(&client->dev, pdata->hpd_irq, anx78xx);

[Severity: High]
This isn't a bug introduced by this patch, but could the INTP interrupt
handler dereference a NULL connector.dev pointer if an interrupt occurs
before the bridge is attached?

Since the interrupt is requested here and enabled immediately, if it fires
before the connector is fully initialized, could the handler crash when
calling drm_helper_hpd_irq_event(anx78xx->connector.dev)?

[Severity: Medium]
This is a pre-existing issue, but does anx78xx_poweroff() and other probe
and bridge enable/disable paths lack mutex locking? Could this cause race
conditions with the threaded interrupt handlers, leading to corrupted
hardware state or imbalanced regulators?

>  		goto err_poweroff;
>  	}
>  
> @@ -1332,6 +1333,14 @@ static void anx78xx_i2c_remove(struct i2c_client *client)
>  {
>  	struct anx78xx *anx78xx = i2c_get_clientdata(client);
>  
> +	/*
> +	 * The threaded IRQ handlers access the dummy I2C clients through
> +	 * regmap and may free the cached EDID, so stop them before those
> +	 * resources are freed below.
> +	 */
> +	devm_free_irq(&client->dev, anx78xx->pdata.hpd_irq, anx78xx);
> +	devm_free_irq(&client->dev, anx78xx->pdata.intp_irq, anx78xx);
> +
>  	drm_bridge_remove(&anx78xx->bridge);

[Severity: Critical]
This is a pre-existing issue, but does removing the bridge here cause a
connector lifetime mismatch and lead to a use-after-free on driver
unbind? If the unbound connector is accessed by the DRM subsystem after
this point, will it trigger a use-after-free?

[Severity: High]
This is a pre-existing issue, but can DRM bridge operations access freed
regmap, regulator, and GPIO resources if called after device removal?
When anx78xx_poweroff() writes to SP_POWERDOWN_CTRL_REG, could it be
accessing freed memory if the bridge outlives the device removal?

>  
>  	unregister_i2c_dummy_clients(anx78xx);

[Severity: High]
This is a pre-existing issue, but is there a missing call to
anx78xx_poweroff() in this driver remove path? Does unbinding the driver
without powering off the chip leave the dvdd10, pd, and reset GPIOs
permanently active instead of turning them off?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260820044746.3087-1-fanwu01@zju.edu.cn?part=1

      reply	other threads:[~2026-08-20  4:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20  4:47 [PATCH] drm/bridge: anx78xx: fix potential use-after-free on device removal Fan Wu
2026-08-20  4:58 ` sashiko-bot [this message]

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=20260820045803.177941F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fanwu01@zju.edu.cn \
    --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.