From nobody Thu Dec 18 12:45:53 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03ED9C38147 for ; Tue, 23 Aug 2022 09:27:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349412AbiHWJ05 (ORCPT ); Tue, 23 Aug 2022 05:26:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349360AbiHWJXy (ORCPT ); Tue, 23 Aug 2022 05:23:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C0868FD44; Tue, 23 Aug 2022 01:35:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DE824B81C55; Tue, 23 Aug 2022 08:33:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11B21C433B5; Tue, 23 Aug 2022 08:33:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243632; bh=okV8wTqSRwwrc7yagPrgh3wP5C7ga5hywXWTASOpLHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YaEvRlgGRw+6bhG2eWGIuCZ3ouoAUpCZmZ/C0NBiVClD9XqYd8VZ7163kVWrcZjIe N6xx7AlR1aEd/luY60RbX2q7spV6hF3IQM9gxerKPBb4y00+jsKAN/AL8U1LYc27yG En54bUhb4q7KBK1ozahJ5ANKTDViaDYdBxE6xJLs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre-Louis Bossart , Ranjani Sridharan , Bard Liao , Mark Brown , Sasha Levin Subject: [PATCH 5.19 339/365] ASoC: SOF: Intel: hda: add sanity check on SSP index reported by NHLT Date: Tue, 23 Aug 2022 10:04:00 +0200 Message-Id: <20220823080132.400854557@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Pierre-Louis Bossart [ Upstream commit e51699505042fb365df3a0ce68b850ccd9ad0108 ] We should have a limited trust in the BIOS and verify that the SSP index reported in NHLT is valid for each platform. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Bard Liao Link: https://lore.kernel.org/r/20220725195343.145603-2-pierre-louis.bossar= t@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/intel/hda.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index ed495b7ad1a9..17f2f3a982c3 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -1395,6 +1395,7 @@ struct snd_soc_acpi_mach *hda_machine_select(struct s= nd_sof_dev *sdev) =20 if (mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER && mach->mach_params.i2s_link_mask) { + const struct sof_intel_dsp_desc *chip =3D get_chip_info(sdev->pdata); int ssp_num; =20 if (hweight_long(mach->mach_params.i2s_link_mask) > 1 && @@ -1404,6 +1405,12 @@ struct snd_soc_acpi_mach *hda_machine_select(struct = snd_sof_dev *sdev) /* fls returns 1-based results, SSPs indices are 0-based */ ssp_num =3D fls(mach->mach_params.i2s_link_mask) - 1; =20 + if (ssp_num >=3D chip->ssp_count) { + dev_err(sdev->dev, "Invalid SSP %d, max on this platform is %d\n", + ssp_num, chip->ssp_count); + return NULL; + } + tplg_filename =3D devm_kasprintf(sdev->dev, GFP_KERNEL, "%s%s%d", sof_pdata->tplg_filename, --=20 2.35.1