]> git.baikalelectronics.ru Git - kernel.git/commit
ALSA: hda/ca0132: fixup buffer overrun at tuning_ctl_set()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 13 Mar 2023 00:50:28 +0000 (00:50 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Apr 2023 09:16:42 +0000 (11:16 +0200)
commitd9a80965efeb3dc08e7100e49913185c6ba62ee6
tree780a7f2981f7524bca34957ff42ff708c19190d4
parentcc38e7e39a9622531d7a1fbb56d663e9cf029a54
ALSA: hda/ca0132: fixup buffer overrun at tuning_ctl_set()

[ Upstream commit 98e5eb110095ec77cb6d775051d181edbf9cd3cf ]

tuning_ctl_set() might have buffer overrun at (X) if it didn't break
from loop by matching (A).

static int tuning_ctl_set(...)
{
for (i = 0; i < TUNING_CTLS_COUNT; i++)
(A) if (nid == ca0132_tuning_ctls[i].nid)
break;

snd_hda_power_up(...);
(X) dspio_set_param(..., ca0132_tuning_ctls[i].mid, ...);
snd_hda_power_down(...);                ^

return 1;
}

We will get below error by cppcheck

sound/pci/hda/patch_ca0132.c:4229:2: note: After for loop, i has value 12
 for (i = 0; i < TUNING_CTLS_COUNT; i++)
 ^
sound/pci/hda/patch_ca0132.c:4234:43: note: Array index out of bounds
 dspio_set_param(codec, ca0132_tuning_ctls[i].mid, 0x20,
                                           ^
This patch cares non match case.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87sfe9eap7.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/pci/hda/patch_ca0132.c