]> git.baikalelectronics.ru Git - kernel.git/commit
ASoC: kirkwood: Iterate over array indexes instead of using pointer math
authorKees Cook <keescook@chromium.org>
Fri, 27 Jan 2023 22:41:29 +0000 (14:41 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:33:58 +0000 (09:33 +0100)
commit4872ae8ae03b022750d9b38723d59b9ae2d34e05
tree0ff0f8d2a84841b55dd7b39cb162d98e9b4f09ee
parentbf671b94aea73db7cd233db29609d8b3ffe4176a
ASoC: kirkwood: Iterate over array indexes instead of using pointer math

[ Upstream commit c1f168fd0318ed5c89fbb707d755b06b6270b489 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/kirkwood/kirkwood-dma.c