Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Kees Cook and committed by
Mark Brown
b3bcedc0 362e8d0f

+1 -1
+1 -1
sound/soc/kirkwood/kirkwood-dma.c
··· 86 86 87 87 /* try to find matching cs for current dma address */ 88 88 for (i = 0; i < dram->num_cs; i++) { 89 - const struct mbus_dram_window *cs = dram->cs + i; 89 + const struct mbus_dram_window *cs = &dram->cs[i]; 90 90 if ((cs->base & 0xffff0000) < (dma & 0xffff0000)) { 91 91 writel(cs->base & 0xffff0000, 92 92 base + KIRKWOOD_AUDIO_WIN_BASE_REG(win));