From: sashiko-bot@kernel.org
To: "Sreeraj S Kurup" <sreekuttan2156239@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH 1/3] ALSA: hda: core: Fix command creation error handling
Date: Thu, 03 Dec 2026 18:12:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-248353@kernel.org> (raw)
In-Reply-To: <20261203170741.3873-2-sreekuttan2156239@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] ALSA: hda: unupdated codec_read() call in
snd_hdac_check_power_state()
- [High] ALSA: hda: unupdated callers after snd_hdac_codec_read()
signature change
- [Medium] ALSA: hda: uninitialized or stale state in
snd_hdac_sync_power_state()
- [Low] ALSA: hda: false 0xffffffff rationale and redundant API redesign
--
commit fe0465b0edab0acacf0e239416a267a90e9cf600
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
ALSA: hda: core: Fix command creation error handling
This commit changes snd_hdac_make_cmd(), codec_read(), and
snd_hdac_codec_read() to return an integer error status and pass the
encoded command or codec response via an output pointer. It also updates
snd_hdac_read(), codec_write(), and snd_hdac_sync_power_state() to check
the returned error status.
> Since 0xffffffff can also be a valid encoded HDA command, callers
> cannot reliably distinguish an invalid command from a valid one.
[Severity: Low]
Is the 0xffffffff premise accurate? Because snd_hdac_make_cmd() limits
nid to 7 bits (nid & ~0x7f) shifted left by 20, bit 27 is always 0 and
0xffffffff can never be encoded; snd_hdac_bus_exec_verb_unlocked() and
codec_exec_verb() already reject cmd == ~0.
Checking snd_hdac_make_cmd() does not require changing the exported
snd_hdac_codec_read() signature, as codec_read() could still return -1
on error, and snd_hdac_read() already provides a status-returning read
helper with an output pointer.
Forwarding caller-supplied res directly to snd_hdac_exec_verb() without
checking for NULL also drops the previous synchronous RIRB wait when a
caller passes NULL and !bus->sync_write.
> diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
> index 682e10a0f6dba..749f70d518344 100644
> --- a/include/sound/hdaudio.h
> +++ b/include/sound/hdaudio.h
> @@ -155,7 +155,7 @@ bool snd_hdac_is_supported_format(struct hdac_device *codec, hda_nid_t nid,
> unsigned int format);
>
> int snd_hdac_codec_read(struct hdac_device *hdac, hda_nid_t nid,
> - int flags, unsigned int verb, unsigned int parm);
> + int flags, unsigned int verb, unsigned int parm, unsigned int *res);
[Severity: High]
Does changing the exported snd_hdac_codec_read() signature here break
compilation for unupdated callers?
snd_hda_codec_read() and snd_hda_codec_write_sync() in
include/sound/hda_codec.h still pass 5 arguments and are never updated
in this series, breaking all legacy HDA codec builds.
When updating snd_hda_codec_write_sync(), it needs a non-NULL dummy res
pointer so snd_hdac_bus_exec_verb_unlocked() does not execute
asynchronously when !bus->sync_write.
The callers in sound/hda/core/hdmi_chmap.c and
sound/soc/codecs/hdac_hdmi.c also fail to compile on this commit,
breaking bisectability until updated in commit "ALSA: hda: hdmi_chmap:
Update HDMI channel map codec read callers" and commit "ASoC: codecs:
hdac_hdmi: Update codec read API callers".
> diff --git a/sound/hda/core/device.c b/sound/hda/core/device.c
> index 6187ffaedbfa3..d43c949af77c2 100644
> --- a/sound/hda/core/device.c
> +++ b/sound/hda/core/device.c
[ ... ]
> @@ -1048,22 +1060,30 @@ bool snd_hdac_is_supported_format(struct hdac_device *codec, hda_nid_t nid,
> }
> EXPORT_SYMBOL_GPL(snd_hdac_is_supported_format);
>
> -static unsigned int codec_read(struct hdac_device *hdac, hda_nid_t nid,
> - int flags, unsigned int verb, unsigned int parm)
> +static int codec_read(struct hdac_device *hdac, hda_nid_t nid,
> + int flags, unsigned int verb, unsigned int parm,
> + unsigned int *res)
[Severity: High]
Was the codec_read() call in snd_hdac_check_power_state() missed here?
snd_hdac_check_power_state() in this same file still invokes
codec_read() with 5 arguments, breaking builds with CONFIG_SND_HDA_CORE
enabled across the series.
When updating it to pass &state, it also needs to check for a negative
return and return true (preserving the prior behavior where -1 had
AC_PWRST_ERROR set) instead of reading an uninitialized state.
[ ... ]
> @@ -1145,8 +1173,11 @@ unsigned int snd_hdac_sync_power_state(struct hdac_device *codec,
> unsigned int state, actual_state, count;
>
> for (count = 0; count < 500; count++) {
> - state = snd_hdac_codec_read(codec, nid, 0,
> - AC_VERB_GET_POWER_STATE, 0);
> + if (snd_hdac_codec_read(codec, nid, 0,
> + AC_VERB_GET_POWER_STATE, 0, &state)) {
> + msleep(20);
> + break;
> + }
> if (state & AC_PWRST_ERROR) {
> msleep(20);
> break;
[Severity: Medium]
Can this return an uninitialized or stale state when
snd_hdac_codec_read() fails?
state is declared uninitialized, and error paths such as call_exec_verb()
failing runtime PM return a negative error without writing *res. A
failure on the first iteration returns an uninitialized stack value,
while a failure on a later iteration returns the previous non-error
state.
Callers like hda_set_power_state() and hdac_hdmi_set_power_state() check
AC_PWRST_ERROR in the returned state to retry failed transitions, and
hda_codec_runtime_suspend() tests state & AC_PWRST_CLK_STOP_OK. Setting
state = AC_PWRST_ERROR (or -1) before breaking preserves the previous
error contract.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203170741.3873-1-sreekuttan2156239@gmail.com?part=1
next prev parent reply other threads:[~2026-12-03 18:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 17:04 [PATCH 0/3] ALSA: hda: Separate codec read status from response Sreeraj S Kurup
2026-12-03 17:05 ` [PATCH 1/3] ALSA: hda: core: Fix command creation error handling Sreeraj S Kurup
2026-12-03 18:12 ` sashiko-bot [this message]
2026-12-03 17:05 ` [PATCH 2/3] ALSA: hda: hdmi_chmap: Update HDMI channel map codec read callers Sreeraj S Kurup
2026-12-03 18:22 ` sashiko-bot
2026-12-03 17:05 ` [PATCH 3/3] ASoC: codecs: hdac_hdmi: Update codec read API callers Sreeraj S Kurup
2026-12-03 18:46 ` sashiko-bot
2026-12-03 17:33 ` [PATCH 0/3] ALSA: hda: Separate codec read status from response Takashi Iwai
2026-12-03 18:10 ` Sreeraj S Kurup
2026-12-03 18:31 ` Sreeraj S Kurup
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-248353@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sreekuttan2156239@gmail.com \
/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