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 24D3463B8 for ; Mon, 20 Feb 2023 13:38:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2C07C4339B; Mon, 20 Feb 2023 13:38:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1676900312; bh=TuylgALl1Y1F7ON6Fsxa/NarENfJF5eVHjsPPGivcEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PitO3AGc55bwyvTCbKc+/wiwu0jRrmfkOAsGxUhzRRqVkkaw6iZqUiySLdRpI3cMp 7OP29TkRDSLL1lsV06PJ9izGb9CVjCyS9qbi11P7bXZvaLlvNYoz2zWoo+lj+a4w/Y 2qX6AHJuV+Vpu2L0CKNn4EgOrbOK+iTMMdnZYPfo= 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 4.14 03/53] ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path() Date: Mon, 20 Feb 2023 14:35:29 +0100 Message-Id: <20230220133548.289741597@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230220133548.158615609@linuxfoundation.org> References: <20230220133548.158615609@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 9dd104c308e1..5ab6d9b3e6d0 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -870,6 +870,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