Skip to content

Commit b9cee50

Browse files
Artemii Karasevtiwai
authored andcommitted
ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path()
snd_hda_get_connections() can return a negative error code. It may lead to accessing 'conn' array at a negative index. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Artemii Karasev <[email protected]> Fixes: 30b4503 ("ALSA: hda - Expose secret DAC-AA connection of some VIA codecs") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent dfd5fe1 commit b9cee50

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sound/pci/hda/patch_via.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,9 @@ static int add_secret_dac_path(struct hda_codec *codec)
819819
return 0;
820820
nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn,
821821
ARRAY_SIZE(conn) - 1);
822+
if (nums < 0)
823+
return nums;
824+
822825
for (i = 0; i < nums; i++) {
823826
if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT)
824827
return 0;

0 commit comments

Comments
 (0)