From: sashiko-bot@kernel.org
To: "Daniel Golle" <daniel@makrotopia.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 01/11] drm/bridge: it6505: quiesce event sources and work on remove()
Date: Wed, 22 Jul 2026 16:22:31 +0000 [thread overview]
Message-ID: <20260722162232.52E141F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <837efb37cc967fc0bb4371d1051dd33838425d2d.1784717129.git.daniel@makrotopia.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Setting `notifier_call` to NULL during unregistration causes a NULL pointer dereference in concurrent extcon notifier traversals.
Pre-existing issues:
- [High] The extcon notifier callback can queue `extcon_wq` after the work has been cancelled, leading to a Use-After-Free of the `it6505` structure.
--
--- Patch [1]: [PATCH v5 01/11] drm/bridge: it6505: quiesce event sources and work on remove() ---
commit ea23622a6daa324ec330db52ae5d71446a7f3ab2
Author: Daniel Golle <daniel@makrotopia.org>
drm/bridge: it6505: quiesce event sources and work on remove()
The patch attempts to fix use-after-free issues during device removal by
unregistering the extcon notifier, disabling IRQs, and cancelling work items
before the devres cleanup frees the it6505 structure. It also initializes the
extcon workqueue in the probe function.
> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> index 8ecb43611dba8..e9c84e4fb3a09 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
[ ... ]
> @@ -2951,13 +2954,16 @@ static int it6505_use_notifier_module(struct it6505 *it6505)
>
> static void it6505_remove_notifier_module(struct it6505 *it6505)
> {
> - if (it6505->extcon) {
> - devm_extcon_unregister_notifier(it6505->dev,
> - it6505->extcon, EXTCON_DISP_DP,
> + mutex_lock(&it6505->extcon_lock);
> + if (it6505->extcon && it6505->event_nb.notifier_call) {
> + devm_extcon_unregister_notifier(it6505->dev, it6505->extcon,
> + EXTCON_DISP_DP,
> &it6505->event_nb);
> -
> - flush_work(&it6505->extcon_wq);
> + it6505->event_nb.notifier_call = NULL;
[Severity: High]
Does setting notifier_call to NULL here cause a NULL pointer dereference in
concurrent extcon notifier traversals?
Extcon uses raw notifiers, which do not provide built-in locking or RCU grace
periods during traversal. If an extcon state change triggers extcon_sync()
(which calls raw_notifier_call_chain()) concurrently with this unbind process,
setting it6505->event_nb.notifier_call to NULL while the traversal thread is
examining this notifier block can cause a crash.
If the traversal thread fetches nb->notifier_call inside notifier_call_chain()
immediately after it is set to NULL, it will attempt to execute it.
> }
> + mutex_unlock(&it6505->extcon_lock);
> +
> + flush_work(&it6505->extcon_wq);
> }
[ ... ]
> @@ -3647,6 +3654,12 @@ static void it6505_i2c_remove(struct i2c_client *client)
> drm_bridge_remove(&it6505->bridge);
> drm_dp_aux_unregister(&it6505->aux);
> it6505_debugfs_remove(it6505);
> + it6505_remove_notifier_module(it6505);
> + disable_irq(it6505->irq);
> + cancel_work_sync(&it6505->link_works);
> + cancel_work_sync(&it6505->hdcp_wait_ksv_list);
> + cancel_delayed_work_sync(&it6505->hdcp_work);
> + cancel_work_sync(&it6505->extcon_wq);
[Severity: High]
This is a pre-existing issue, but does this fully prevent a Use-After-Free
if the extcon notifier callback is running concurrently?
In it6505_remove_notifier_module(), devm_extcon_unregister_notifier() removes
the raw notifier but does not wait for concurrently executing callbacks to finish.
If the it6505_extcon_notifier() callback is executing or preempted on another
CPU, it can call schedule_work(&it6505->extcon_wq) after cancel_work_sync()
returns.
When the device unbinds, devres frees the it6505 structure, which can cause
the scheduled workqueue to dereference freed memory.
> it6505_poweroff(it6505);
> it6505_remove_edid(it6505);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1784717129.git.daniel@makrotopia.org?part=1
next prev parent reply other threads:[~2026-07-22 16:22 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 15:45 [PATCH v5 00/11] drm/bridge: it6505: DP audio support + shared-DAI hw_params fix Daniel Golle
2026-07-22 15:45 ` [PATCH v5 01/11] drm/bridge: it6505: quiesce event sources and work on remove() Daniel Golle
2026-07-22 16:22 ` sashiko-bot [this message]
2026-07-22 15:45 ` [PATCH v5 02/11] drm/bridge: it6505: balance and disable runtime PM on remove Daniel Golle
2026-07-22 20:36 ` sashiko-bot
2026-07-22 15:45 ` [PATCH v5 03/11] drm/bridge: it6505: unregister DP AUX adapter on bridge detach Daniel Golle
2026-07-22 20:46 ` sashiko-bot
2026-07-22 15:46 ` [PATCH v5 04/11] drm/bridge: it6505: complete poweroff even if disabling regulators fails Daniel Golle
2026-07-22 20:58 ` sashiko-bot
2026-07-22 15:46 ` [PATCH v5 05/11] drm/bridge: it6505: bail out of the IRQ handler when status reads fail Daniel Golle
2026-07-22 15:46 ` [PATCH v5 06/11] drm/bridge: it6505: avoid division by zero in pixel clock calculation Daniel Golle
2026-07-22 15:46 ` [PATCH v5 07/11] drm/bridge: it6505: avoid division by zero in audio FS debug print Daniel Golle
2026-07-22 21:23 ` sashiko-bot
2026-07-22 15:47 ` [PATCH v5 08/11] drm/bridge: it6505: guard against zero channel count in audio infoframe Daniel Golle
2026-07-22 15:47 ` [PATCH v5 09/11] drm/bridge: it6505: hold endpoint OF node reference while parsing it Daniel Golle
2026-07-22 21:52 ` sashiko-bot
2026-07-22 15:47 ` [PATCH v5 10/11] drm/bridge: it6505: Add audio support Daniel Golle
2026-07-22 22:07 ` sashiko-bot
2026-07-22 15:47 ` [PATCH v5 11/11] drm/bridge: it6505: Don't reject audio hw_params without an encoder Daniel Golle
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=20260722162232.52E141F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=daniel@makrotopia.org \
--cc=dri-devel@lists.freedesktop.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 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.