From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796321534; b=rKfV4MxDZlAmvqtIasQGL4rhXSirZgAhSlnx4VRO5FWb6FaE0VtdAAPJ2vlnhfdHI/nB ibHcbcajRORJ1DV59b2EBbKutmnxoZ1vp6EyyJ8kHxRuOfoL4R2zCtCS3K08cMt3ZVMH9 7pLjLzumvWdh29iYGZw+4QFyOG88L+EoxOyUP3JDEYX/hegvXCPISTV3II0bX9uJ5E6VD pJ4Ldr4sfyHaWwNBYf2QBQ6JSpxLg/CVJ4Q0xxS9eFQ3e3cDl0tRJN/kfQcslE/fIVdHt iDh/iX506c6CnXhdDDYZkVoAut1qA2Y8qa0l8iXmw3QCah4UAB3gNdpyi8CSS9gENQg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796321534; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=o+GmjONQ+W1iSKtdDTq49AkgyeSX8MQQfp8jocoXmFE=; b=hlZ7FF31SyrnTbP2RLIKqZtmMvumrSsC8U+VQW21YNu4srpUH3XDg2P6toHk02UVDq0P bLsiVc487cTT+jx2m8rAhck6HAQBoUilT/x4dMy/e4QWCWtu19sPyCvyLci2Qb6QJ5aDB 6XIEyto/P5GV1XGYJibCngajQmTkMV8ff+eMW5Dg9pIW6ZR+peRvOnuynvPSTIlJtUXF3 YB72rTvmWXBpsgf4f8LaqIM8UkC9lCxoij7TPB6AFjaKwH6l6/CVXKPqVYeoqVziYAzoZ mKsq8S437aGHRXiOdWi0aR2/rLrnVpkD8dT99/BEP2AdhziJrC7n10GdT/PuoOVnrpA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VihyfjMs; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD543606A322 for ; Thu, 3 Dec 2026 18:12:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VihyfjMs Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A2A21F0089A; Thu, 3 Dec 2026 18:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796321534; bh=o+GmjONQ+W1iSKtdDTq49AkgyeSX8MQQfp8jocoXmFE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=VihyfjMsYut9FXGUckgao7mZP4XvX0ef1iO28N8bZgcJL/NcCHfqqxkqu2K2rWcJt CS45ZBQimE6mmFOEM3vUpR92xl/gdWgtnOd4jnjSBOy9JAbb6o7+uv0fS87Xo6jUEE Qx8YijSl1wqnPtXmy83hnbu3R5rNWLc7k0IB53/iRDm9d73UIHRIzTBVlS1td+ggsl ZuSH5C5adIzaqcopzrJdTgFw2csB/lecAntXLqyNHK+TEtOlBshf6j9Ryk18cYW2sG bGH/k6TuN7Hcbp3+S89SRtxy9KVurWtX04j2EmaQzMDkwkBgzxxuJ0SQk3m6zik2+7 25XJWowglrj+g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 1/3] ALSA: hda: core: Fix command creation error handling Reply-To: sashiko-reviews@lists.linux.dev To: "Sreeraj S Kurup" Cc: linux-sound@vger.kernel.org In-Reply-To: <20261203170741.3873-2-sreekuttan2156239@gmail.com> References: <20261203170741.3873-1-sreekuttan2156239@gmail.com> <20261203170741.3873-2-sreekuttan2156239@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 18:12:13 +0000 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 =3D=3D ~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); > =20 > 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_dev= ice *codec, hda_nid_t nid, > } > EXPORT_SYMBOL_GPL(snd_hdac_is_supported_format); > =20 > -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; > =20 > for (count =3D 0; count < 500; count++) { > - state =3D 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 =3D AC_PWRST_ERROR (or -1) before breaking preserves the previous error contract. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203170741.3873= -1-sreekuttan2156239@gmail.com?part=3D1