Skip to contentSkip to conversation

ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path()

PATCH Applied Artemii Karasev 2 participants 2 messages Jan 19, 2023 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Fixes 30b4503378c9 ("ALSA: hda - Expose secret DAC-AA connection of some VIA codecs")
---
 sound/pci/hda/patch_via.c | 3 +++
 1 file changed, 3 insertions(+)
sound/pci/hda/patch_via.c +3 -0
index aea7fae2ca4b..2994f85bc1b9 100644
@@ -819,6 +819,9 @@ static int add_secret_dac_path(struct hda_codec *codec)
 		return 0;
 	nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn,
 				       ARRAY_SIZE(conn) - 1);
+	if (nums < 0)
+		return nums;
+
 	for (i = 0; i < nums; i++) {
 		if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT)
 			return 0;
Signature · 1 line
2.25.1
Applied
#1 lore raw
Quoted 8 lines · Artemii Karasev

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.

Fixes 30b4503378c9 ("ALSA: hda - Expose secret DAC-AA connection of some VIA codecs")

Thanks, applied.

Takashi