From patchwork Mon Jul 25 19:53:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 593290 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96FA0C43334 for ; Mon, 25 Jul 2022 19:55:41 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BBC4EAE8; Mon, 25 Jul 2022 21:54:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BBC4EAE8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1658778939; bh=/igeBZwE6dzF0iNudQYu7rD4hBbaXOoTcWrbYWEUHoU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=XUMTHzN31iKXlcgeZGFVbp9ARfADyfI+/5uv0W/SR25BscfSO8IunX95Vcu/c/4nV 1/GjzsBtEfJFQIXWqUFkuRRHzkA2UnQASFRgols5LamCVGubbdjIJxlXyalG50UEmC XIXIKgHmAYkOUla82zlGWE27R+xTZyLKdApYE8WU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 16324F804FD; Mon, 25 Jul 2022 21:54:04 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 88D81F80543; Mon, 25 Jul 2022 21:54:02 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id EAB58F80128 for ; Mon, 25 Jul 2022 21:53:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EAB58F80128 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="H5SeM+v/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658778837; x=1690314837; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/igeBZwE6dzF0iNudQYu7rD4hBbaXOoTcWrbYWEUHoU=; b=H5SeM+v/yjJUthiUIL5Xvt8jo2BpQNVHksrIW7uff3tTOVBGWjKxjB6u mm7225/IYfJU/ZrxiER8aM0dVrmOxbThWwfM/OyLXQOVyEvd2sJoSiyks CXnT7vs0T2F+eo25ZmpNJiPXcxIGUB1WOmn9q27qTW7C4DUn34ob2/+G8 wezQKAsT9b5yJ7K+tQctfKG6rk9pbpkpZIlj7DcVTnIAHLpXKyV6obXe5 +XIOtR89ALaJzAhE97cFZauamAmgSjkld+eXV01YzV/J/QVBPXSR3bqP+ xL0cE3/ElO+bR0fOYmZoIE8VFlM2teZ3QtuBQwrsXItVMCKZoCwqu5dq+ A==; X-IronPort-AV: E=McAfee;i="6400,9594,10419"; a="270820359" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="270820359" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 12:53:51 -0700 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="627593492" Received: from mbianco-mobl1.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.212.71.159]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 12:53:51 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [PATCH 1/3] ASoC: SOF: Intel: hda: add sanity check on SSP index reported by NHLT Date: Mon, 25 Jul 2022 14:53:41 -0500 Message-Id: <20220725195343.145603-2-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220725195343.145603-1-pierre-louis.bossart@linux.intel.com> References: <20220725195343.145603-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: tiwai@suse.de, broonie@kernel.org, Bard Liao , Pierre-Louis Bossart , Ranjani Sridharan X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 --- 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 d337d55050e2..8639ea63a10d 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -1527,6 +1527,7 @@ struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev) if (tplg_fixup && mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER && mach->mach_params.i2s_link_mask) { + const struct sof_intel_dsp_desc *chip = get_chip_info(sdev->pdata); int ssp_num; if (hweight_long(mach->mach_params.i2s_link_mask) > 1 && @@ -1536,6 +1537,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 = fls(mach->mach_params.i2s_link_mask) - 1; + if (ssp_num >= 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 = devm_kasprintf(sdev->dev, GFP_KERNEL, "%s%s%d", sof_pdata->tplg_filename,