提交 8eecc006 编写于 作者: A Artemii Karasev 提交者: zhaoxiaoqiang11

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

stable inclusion
from stable-v5.10.168
commit 2b557fa635e7487f638c0f030c305870839eeda2
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7URR4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2b557fa635e7487f638c0f030c305870839eeda2

----------------------------------------------------

[ Upstream commit b9cee506 ]

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: NArtemii 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.ruSigned-off-by: NTakashi Iwai <tiwai@suse.de>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
上级 d3b5c638
...@@ -821,6 +821,9 @@ static int add_secret_dac_path(struct hda_codec *codec) ...@@ -821,6 +821,9 @@ static int add_secret_dac_path(struct hda_codec *codec)
return 0; return 0;
nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn, nums = snd_hda_get_connections(codec, spec->gen.mixer_nid, conn,
ARRAY_SIZE(conn) - 1); ARRAY_SIZE(conn) - 1);
if (nums < 0)
return nums;
for (i = 0; i < nums; i++) { for (i = 0; i < nums; i++) {
if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT) if (get_wcaps_type(get_wcaps(codec, conn[i])) == AC_WID_AUD_OUT)
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册