Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp668778rwb; Thu, 19 Jan 2023 00:45:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXtNdGLm2TcCG05PSv0V2RqjNNaeKxaiXT3oxBMdwi4UbWK4/NNxdW/9AH3bvZoyej3ZQvRJ X-Received: by 2002:aa7:cd15:0:b0:472:cee9:bbd3 with SMTP id b21-20020aa7cd15000000b00472cee9bbd3mr10807851edw.27.1674117934777; Thu, 19 Jan 2023 00:45:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674117934; cv=none; d=google.com; s=arc-20160816; b=fbiX4hWkjoARteXph3c2gyoZvQLCHfpjDPb4gHBbRM0nXcwraeRfJ+NfCsFVGD1l6/ YhmzfPBdcJcAQvVpc7PuvLYY9ixtqwpvDlMcQmV5FF0ZqPWyrdTNtvlSjfBDUWPDA49J ChcCImrpLRbCrv7GPjDwepX5edOROKIvSRy5FRFZGa1kkOnlojQ7/e3mWmXcStg+ON2R a2pXp8jP47jK7u725FKmvhyCGFf2LRLAFEqPHYmZtQqBjkIGCrvkzUAC2q+U8iuSEvzy jVL8ZTz2ob5fX/Ipw2DQ63H6iLFu8cEmgjq/6uS4kvD2z5T/TmFWrlFnC/Ya6z88seqc T+1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=yplRY5vy0IwvvCxj1QobBKOGx3GZDSpgAOeKTO9wQuc=; b=V5YU2ZEQdtlk6GAmMvlXrvVqLMZ0wmXnZWcuKPt3MrYQoCEoPwnW3N3X0gz4lC0uON zW4p9A+ihIdP/dvg8/IJdDERs0rhLCQwnn5Zy2owPPLjRJDcmi5HAxuVQ86p2TXTHfDY 1Nt73ITVBilBdhRxP2nEGiG6I01ZKIyKlFETuP+kqb/kOPT449IhUSe4Cpd6lyndFxZ9 UIEjHwUDXF08GM6GoNHrKHrGLTUPn6I/pMPMBw5CXUjn+uftuHq7VFTjsN+Z02idGqn3 flxx6wLzlaRRho+RLdRqPm1lfab7eHy0gyahENVDj5JIlo3X6abRT+WkChwdEcELYCSQ 5FnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=QK9sullm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dz13-20020a0564021d4d00b0049e746e3a83si713428edb.419.2023.01.19.00.45.23; Thu, 19 Jan 2023 00:45:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=QK9sullm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbjASIXg (ORCPT + 44 others); Thu, 19 Jan 2023 03:23:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230117AbjASIX0 (ORCPT ); Thu, 19 Jan 2023 03:23:26 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA1F74F34C for ; Thu, 19 Jan 2023 00:23:23 -0800 (PST) Received: from ubuntu.localdomain (unknown [46.146.89.18]) by mail.ispras.ru (Postfix) with ESMTPSA id 582D3406BB55; Thu, 19 Jan 2023 08:23:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 582D3406BB55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1674116601; bh=yplRY5vy0IwvvCxj1QobBKOGx3GZDSpgAOeKTO9wQuc=; h=From:To:Cc:Subject:Date:From; b=QK9sullmZm/qV9iOheODkQeV+m5raFyFrR4nOUQSwrqdGdpIS5MYkK9AflobwBeWO y4i3vcJVsgFiJJD7fb01uwmXELwkgw49WH+ADppBaIn7M2ZarlwH35llHN1m+at6sS Acy7njboJG67Ke917zMzBWkqP+39aL4fSk/BSb0I= From: Artemii Karasev To: Jaroslav Kysela , Takashi Iwai Cc: Artemii Karasev , Xiang wangx , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path() Date: Thu, 19 Jan 2023 00:22:59 -0800 Message-Id: <20230119082259.3634-1-karasev@ispras.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") --- 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 aea7fae2ca4b..2994f85bc1b9 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -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; -- 2.25.1