Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6870f38 authored by Artemii Karasev's avatar Artemii Karasev Committed by Greg Kroah-Hartman
Browse files

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



[ Upstream commit b9cee506da2b7920b5ea02ccd8e78a907d0ee7aa ]

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: default avatarArtemii Karasev <karasev@ispras.ru>
Fixes: 30b45033 ("ALSA: hda - Expose secret DAC-AA connection of some VIA codecs")
Link: https://lore.kernel.org/r/20230119082259.3634-1-karasev@ispras.ru


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 412fddc0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -821,6 +821,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;