diff options
author | Kees Cook <keescook@chromium.org> | 2023-01-27 14:41:29 -0800 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2023-01-28 10:51:05 +0000 |
commit | b3bcedc0402fcdc5c8624c433562d9d1882749d8 (patch) | |
tree | f26737954248f6c1ae612a0202792263f728da67 /sound/soc/kirkwood | |
parent | 362e8d0f27c40864b4f8994624409f7b4316d2dd (diff) | |
download | linux-stable-b3bcedc0402fcdc5c8624c433562d9d1882749d8.tar.gz linux-stable-b3bcedc0402fcdc5c8624c433562d9d1882749d8.tar.bz2 linux-stable-b3bcedc0402fcdc5c8624c433562d9d1882749d8.zip |
ASoC: kirkwood: Iterate over array indexes instead of using pointer math
Walking the dram->cs array was seen as accesses beyond the first array
item by the compiler. Instead, use the array index directly. This allows
for run-time bounds checking under CONFIG_UBSAN_BOUNDS as well. Seen
with GCC 13 with -fstrict-flex-arrays:
../sound/soc/kirkwood/kirkwood-dma.c: In function
'kirkwood_dma_conf_mbus_windows.constprop':
../sound/soc/kirkwood/kirkwood-dma.c:90:24: warning: array subscript 0 is outside array bounds of 'const struct mbus_dram_window[0]' [-Warray-bounds=]
90 | if ((cs->base & 0xffff0000) < (dma & 0xffff0000)) {
| ~~^~~~~~
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230127224128.never.410-kees@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/kirkwood')
-rw-r--r-- | sound/soc/kirkwood/kirkwood-dma.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c index 700a18561a94..640cebd2983e 100644 --- a/sound/soc/kirkwood/kirkwood-dma.c +++ b/sound/soc/kirkwood/kirkwood-dma.c @@ -86,7 +86,7 @@ kirkwood_dma_conf_mbus_windows(void __iomem *base, int win, /* try to find matching cs for current dma address */ for (i = 0; i < dram->num_cs; i++) { - const struct mbus_dram_window *cs = dram->cs + i; + const struct mbus_dram_window *cs = &dram->cs[i]; if ((cs->base & 0xffff0000) < (dma & 0xffff0000)) { writel(cs->base & 0xffff0000, base + KIRKWOOD_AUDIO_WIN_BASE_REG(win)); |