From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD76063B8 for ; Mon, 20 Feb 2023 13:43:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E32BC433EF; Mon, 20 Feb 2023 13:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1676900639; bh=JOh+/fR9fzqSRDzRE13SEIhj1PEFpmdmWhOUrWxKY/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H+9FAJVIJO993DpOe3/ZfnnK7q6BNARQqCUWkmUhEw4jyPMMkacds2S1clowPMHXX EijsQuBGnxYxDMe/Ss/nS/aLWoERR2hVqeWT61sC+riPj0/bgYwM8uyLMGFbinsuRG RmshSMKcKrvZjO0u+OssVt843Bp01d8w+EEEptFE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Artemii Karasev , Takashi Iwai , Sasha Levin Subject: [PATCH 5.4 004/156] ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path() Date: Mon, 20 Feb 2023 14:34:08 +0100 Message-Id: <20230220133602.673456325@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230220133602.515342638@linuxfoundation.org> References: <20230220133602.515342638@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Artemii Karasev [ 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: Artemii Karasev Fixes: 30b4503378c9 ("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: Takashi Iwai Signed-off-by: Sasha Levin --- sound/pci/hda/patch_via.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 3edb4e25797d..4a74ccf7cf3e 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -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; -- 2.39.0