From: sashiko-bot@kernel.org
To: "Frank Zhang" <rmxpzlb@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/bridge: dw-hdmi-qp: Guard clear_audio_infoframe when PHY is down
Date: Tue, 08 Sep 2026 06:41:01 +0000 [thread overview]
Message-ID: <20260908064101.87FC61F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908062708.39437-1-rmxpzlb@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing synchronization lock between DRM atomic disable and ALSA callbacks leaves a Time-Of-Check to Time-Of-Use (TOCTOU) race condition, failing to fix the kernel panic.
--
commit 41e47d6bcdba49646deba6ac74845c934529f2f4
Author: Frank Zhang <rmxpzlb@gmail.com>
drm/bridge: dw-hdmi-qp: Guard clear_audio_infoframe when PHY is down
This commit attempts to fix a kernel panic caused when an audio server
closes the HDMI audio device concurrently with an atomic_disable. It tries
to guard register accesses in the audio teardown path by checking the
tmds_char_rate state variable.
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
> index cfd1b18c06e62..f0e9324249d66 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
[ ... ]
> @@ -893,6 +893,16 @@ static int dw_hdmi_qp_bridge_clear_audio_infoframe(struct drm_bridge *bridge)
> return 0;
> }
>
> +static int dw_hdmi_qp_bridge_clear_audio_infoframe(struct drm_bridge *bridge)
> +{
> + struct dw_hdmi_qp *hdmi = bridge->driver_private;
> +
> + if (hdmi->tmds_char_rate > 0)
> + return __dw_hdmi_qp_bridge_clear_audio_infoframe(bridge);
> +
> + return 0;
> +}
> +
[Severity: High]
This isn't a bug introduced by this patch, but does this lockless check
leave an open Time-Of-Check to Time-Of-Use (TOCTOU) race condition?
If a userspace audio server (like pipewire) closes the HDMI audio device at
the same time as a DRM modeset disables the display, the ALSA teardown path
can execute dw_hdmi_qp_bridge_clear_audio_infoframe() and successfully
evaluate this unguarded check.
Concurrently, dw_hdmi_qp_bridge_atomic_disable() can execute:
hdmi->tmds_char_rate = 0;
hdmi->phy.ops->disable(hdmi, hdmi->phy.data);
This zeroes the state variable and powers off the PHY without
synchronization. The ALSA thread can then resume and invoke
__dw_hdmi_qp_bridge_clear_audio_infoframe(), writing to the now-disabled
PHY registers and triggering the Asynchronous SError Interrupt panic this
patch is trying to fix.
Additionally, could the same race exist in dw_hdmi_qp_audio_prepare()?
if (!hdmi->tmds_char_rate)
return -ENODEV;
// ... further down ...
dw_hdmi_qp_set_audio_interface(hdmi, fmt, hparms);
This path configures multiple registers after a lockless check, making the
entire preparation sequence vulnerable to the same race condition.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908062708.39437-1-rmxpzlb@gmail.com?part=1
next prev parent reply other threads:[~2026-09-08 6:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 6:27 [PATCH] drm/bridge: dw-hdmi-qp: Guard clear_audio_infoframe when PHY is down Frank Zhang
2026-09-08 6:41 ` sashiko-bot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-04-16 9:31 Frank Zhang
2026-04-17 16:46 ` Detlev Casanova
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=20260908064101.87FC61F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=rmxpzlb@gmail.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;
as well as URLs for NNTP newsgroup(s).