From: Ian Rogers <irogers@google.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Elkin Cruz <elkin@google.com>,
Ian Rogers <irogers@google.com>
Subject: [PATCH] ASoC: codecs: aw88395: Validate 4-byte alignment and init ret in reg update
Date: Thu, 19 Nov 2026 09:10:59 -0800 [thread overview]
Message-ID: <20261119171059.1537658-1-irogers@google.com> (raw)
In aw_dev_update_reg_container(), each register entry consists of two
16-bit values (4 bytes). Because 'data_len = len >> 1' shifts off bit
0 before checking 'data_len & 0x1', byte lengths with (len & 0x3) == 1
bypass validation: len == 1 yields data_len == 0, executing zero loop
iterations and returning an uninitialized ret, while larger odd
lengths silently ignore the trailing byte.
Reject any length with (len & 0x3) != 0 and initialize ret to 0.
Found via Clang -Wconditional-uninitialized on an x86_64 allyesconfig
build. Verified by building
sound/soc/codecs/aw88395/aw88395_device.o with LLVM=1 W=1 (-Werror)
and -Wconditional-uninitialized, and with a standalone C reproducer;
not runtime-tested on AW88395 hardware.
Fixes: 06d2fe9cb423 ("ASoC: codecs: Aw88395 function for ALSA Audio Driver")
Signed-off-by: Ian Rogers <irogers@google.com>
---
sound/soc/codecs/aw88395/aw88395_device.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/aw88395/aw88395_device.c b/sound/soc/codecs/aw88395/aw88395_device.c
index 3ae418c8b34e..2dd0b3b7de0d 100644
--- a/sound/soc/codecs/aw88395/aw88395_device.c
+++ b/sound/soc/codecs/aw88395/aw88395_device.c
@@ -1004,16 +1004,16 @@ static int aw_dev_update_reg_container(struct aw_device *aw_dev,
u16 read_vol;
u16 reg_val;
u8 reg_addr;
- int i, ret;
-
- reg_data = (int16_t *)data;
- data_len = len >> 1;
+ int i, ret = 0;
- if (data_len & 0x1) {
- dev_err(aw_dev->dev, "data len:%d unsupported", data_len);
+ if (len & 0x3) {
+ dev_err(aw_dev->dev, "data len:%u unsupported\n", len);
return -EINVAL;
}
+ reg_data = (int16_t *)data;
+ data_len = len >> 1;
+
for (i = 0; i < data_len; i += 2) {
reg_addr = reg_data[i];
reg_val = reg_data[i + 1];
--
2.56.1.708.g77570a6a1d-goog
reply other threads:[~2026-11-19 17:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261119171059.1537658-1-irogers@google.com \
--to=irogers@google.com \
--cc=broonie@kernel.org \
--cc=elkin@google.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=perex@perex.cz \
--cc=tiwai@suse.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
all inboxes | Powered by JetHome®