Linux Sound subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Roy <rongh7426@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH] ASoC: hdmi-codec: Clear the parsed ELD on unplug
Date: Thu, 26 Nov 2026 10:43:29 +0000	[thread overview]
Message-ID: <sashiko-outbox-235311@kernel.org> (raw)
In-Reply-To: <20261126103757.655758-1-rongh7426@gmail.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] ASoC: hdmi-codec: data races in ELD structures handling [1]
--

commit b249243bd16fd50e607cc3aaff9399c455c37747
Author: Roy <rongh7426@gmail.com>

ASoC: hdmi-codec: Clear the parsed ELD on unplug

This commit clears hcp->eld_parsed in plugged_cb() when an HDMI sink is
unplugged so that the eld#N procfs file does not report stale monitor data.

> diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
> index bc59da295370c..ff4fa9fbbf68c 100644
> --- a/sound/soc/codecs/hdmi-codec.c
> +++ b/sound/soc/codecs/hdmi-codec.c
> @@ -973,6 +973,7 @@ static void plugged_cb(struct device *dev, bool plugged)
>  	} else {
>  		hdmi_codec_jack_report(hcp, 0);
>  		memset(hcp->eld, 0, sizeof(hcp->eld));
> +		memset(&hcp->eld_parsed, 0, sizeof(hcp->eld_parsed));
>  	}
>  }

[Severity: High]
This problem wasn't introduced by this patch, but can plugged_cb() race with
hdmi_codec_startup(), print_eld_info(), and hdmi_eld_ctl_get() on hcp->eld
and hcp->eld_parsed [1]?

plugged_cb() updates and clears both ELD structures without holding
hcp->lock, while hdmi_codec_startup() mutates them under hcp->lock:

CPU0                                CPU1
plugged_cb()                        hdmi_codec_startup()
                                      guard(mutex)(&hcp->lock);
  hcp->hcd.ops->get_eld(...)          hcp->hcd.ops->get_eld(...)
  snd_parse_eld(...)                  snd_parse_eld(...)  <-- data race

print_eld_info() and hdmi_eld_ctl_get() also read hcp->eld_parsed and
hcp->eld without acquiring hcp->lock, so a concurrent hotplug event can
expose partially updated ELD state (such as a non-zero sad_count before the
SAD array is populated or while it is being zeroed) and corrupt procfs or
ALSA control output.

[1] https://sashiko.dev/#/bug/linux-80b0f2ca-0e91-4822-89fb-4074f7b4e06b

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126103757.655758-1-rongh7426@gmail.com?part=1

  reply	other threads:[~2026-11-26 10:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 10:37 [PATCH] ASoC: hdmi-codec: Clear the parsed ELD on unplug Roy
2026-11-26 10:43 ` sashiko-bot [this message]
2026-11-26 16:31 ` Mark Brown

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=sashiko-outbox-235311@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=rongh7426@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