From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (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 553C9378830 for ; Thu, 28 May 2026 08:21:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779956522; cv=none; b=EyleQ56Ca9cLSt26HmdRn2n/8JCPChVoUiG4cGJIUClTLVqKKSB1EDbfK6vpXIBsq5vyS/o+EUm5mWTLlsWuucXkZMb9Vefx3n49QaAFRgzPN5d59h74+iccgv/j+SDHCDHEwGJS3RQI3hzGqyKpIF8aruxmmNKKl3oIXzPePVA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779956522; c=relaxed/simple; bh=tMlVnv3Uy19bG/0AHjUIqwe3ZzVat/FDbzFrTjl+D4I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kHFVRarKiIRXWFKwEpJnKQ5tSOK4GuQ+QMu3aZ9Cv8/mkgMAwOayFX/BByLAo5EfKTBHEZb+XI6uvNy2QleueEy4y2ywhsg2u7WtPrttRYplboRytkNw6HHKW5JhuKZccsBCb+lzOHQDZn8eAQpB1wfKBq8KJLBrmQlFZ0BgJig= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (4096-bit key) header.d=canonical.com header.i=@canonical.com header.b=lsIRyI9h; arc=none smtp.client-ip=185.125.188.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=canonical.com header.i=@canonical.com header.b="lsIRyI9h" Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id C149A3F9B8 for ; Thu, 28 May 2026 08:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20251003; t=1779956511; bh=ABJGuulrA8nUHwEQn+jZIDmSNh6kAiqySDUWEGzSLYE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lsIRyI9h/qWeii/gXdkVJ8EzMp/AV2CFtKln+NGgXBS+91K+to08V6rYLt+mJ5vJo R0iuufQ149cAXyWVQCw9vojCVH3Q3ttjGZg7R3tKPjssMASuxeGKiiJX6/ufEncjeS YSk9e6LcREl9n1WmqZRjhVTli81qng01/wNBCczHA5BFIg2rhSj0N34Ht97/+sqTxd PHw7GaTSKwsYvDsaWC1SAiAWgNv5gKm4F4yUW27/hEXGnvlF9hT6MTb41AUW6r2JCd OSh6+xRpdu6waUe3M2hQ85fxRxQWDGzcEKLw3ugRQv9jq6CT3d5F+WhfszcCc77+CV jJtj0mrkTc63Yg4to31vKQroKRZNCiIME/MgwDagv1zdpkuXRA0dq6dD1I+faCPnO1 uza3D+eBN8cwru6+i1fwkurA1zJOGyGwBDTvdokPufDJMcIRybUZHKmAFpdwduaxWK cemvDqbJWGA7WYc7LSFItyd12P8Vc6ZGscToyFBodFJMXdQHZBDmxcLR59XKMdLJ7E RQwjDDpk+IrsFpOeceqyS8OqTNkEPTg57+uyc/TdMHP2kjeeJr+fjBt1aRVkcXMYEX Sk9DVF5d9q0U5iEhq2xriO1eXjneJKB82nSRsUwf5et/akJcxIYb8C1+raL24e7Xge Hj3lk9DgjASenjM7e6Z5B7So= Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49048bcbeb8so69460285e9.2 for ; Thu, 28 May 2026 01:21:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779956511; x=1780561311; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ABJGuulrA8nUHwEQn+jZIDmSNh6kAiqySDUWEGzSLYE=; b=djJITg1O6sY5+WlK+2ulQ59a4cVEk0BHfE00QOpmv2GALCoY6tJ4saSqmrgn8Q8l2d xdEh5EiVbNIoix7tBE4YId4C9WYOwBg9sIc8ktlS40z4EVpmupwlfE14BjTu+4xpnEC6 Nh0Xo16Ze4aPO4U29V+6J/NsUEthrZY3LI7bBH+bmCyoffHTrv3IXHL+9LFeIolCpyg6 FAyI/ArBt0q3t3jegL0jYKTBor8/Hrmm8XB+EpgAIyyzD5mpplA6GufJZzxrI/ampUOE +IjM9r130rYQ1LkPbIezfMbNfb1CdRMgoVR9A8oz6bwVtz0kDh+JHGgTicGrajEpIESN jUxg== X-Forwarded-Encrypted: i=1; AFNElJ/N9TARFB44lQqH43btzTxH5qYKWXv8wzqLSK5pr5B96XMrCrhgaOJaGa4plmLAfys3JPMhKOHflD36/5U=@vger.kernel.org X-Gm-Message-State: AOJu0Yyk2F5ykEMwSJJA4MPbuYuGT9pNp0uIWCxCk0ipJi2hts6Fw7YA yCBGfKw+2ANLbEpI2qDr0MkT8Y7jgZDGZM1YDn7sDsn79eso+7En7gwi9vvi01trEHkLSaCnbbD vRBM4vRftoSm5C4JbZyCr6YChd7tT1zjspICWK8X4XfgBiBtuVG1eYPYWJYxjtoALggYn8fbkTp KBM0ZjrzbE2lk56Pwe X-Gm-Gg: Acq92OHO2UhV47kA5v2BuzQPI9eQdL93+0zfZttX1Fa/BAnjDLBov02aDZy9xsMssLK BE06pCeEesfsH/akdohdDYzTl9xWre74QOgxDQKwBgdwUaLd1FPwYLPFwVKw3BjJraHu3LgBRJc R+26D6rubUq0FRLaH96gy7PHEAjBBY21QkEEMe7egyrxgnW8036ZGlZZv99Blkh+FaWdFIlm7hd kJIqls8abQ7eSccflhTx2MXIWgEZMvR98Ddr072j+jS8w8DONpu+0T2wCW66apoXwBpxYXBmMcZ MnRXLL9gIDjvszkv3z5hDR94r6DRfQbpR6PfV4hETFj84XQdnCTG6jydo6CnexkUEzmbQwQAduc wMnv/3LlGtDdKMHuSgoHQM58ksaC95l4ZvMLM/G3K52DD/mccEMC7Oq7838rFUfLPBjF+t2tdrK EGczxkk+Y27OavQK8CZmb5jrd44NIGtA== X-Received: by 2002:a05:600c:818e:b0:490:58f4:ba23 with SMTP id 5b1f17b1804b1-4905c60ef29mr292847555e9.30.1779956511317; Thu, 28 May 2026 01:21:51 -0700 (PDT) X-Received: by 2002:a05:600c:818e:b0:490:58f4:ba23 with SMTP id 5b1f17b1804b1-4905c60ef29mr292847195e9.30.1779956510902; Thu, 28 May 2026 01:21:50 -0700 (PDT) Received: from localhost.localdomain ([103.155.100.10]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49092a902bfsm42284605e9.12.2026.05.28.01.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 01:21:50 -0700 (PDT) From: Aaron Ma To: Vijendar Mukunda , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Venkata Prasad Potturu , "Mario Limonciello (AMD)" , Charles Keepax , Syed Saba Kareem , Krzysztof Kozlowski , Mark Pearson , Hasun Park , Kees Cook , Li Qiang , Bard Liao Subject: [PATCH 1/2] ASoC: amd: acp-sdw-legacy: Bound DAI link iteration Date: Thu, 28 May 2026 16:21:09 +0800 Message-ID: <20260528082110.915549-1-aaron.ma@canonical.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit create_sdw_dailinks() walks soc_dais until it finds an entry with initialised cleared, but soc_dais is allocated with exactly num_ends entries. If all entries are initialised, the loop reads past the end of the array. This was reported by KASAN: BUG: KASAN: slab-out-of-bounds in mc_probe+0x26b3/0x2774 [snd_acp_sdw_legacy_mach] Read of size 1 Pass the allocated entry count to create_sdw_dailinks() and stop before reading past the array. Fixes: 2981d9b0789c ("ASoC: amd: acp: add soundwire machine driver for legacy stack") Signed-off-by: Aaron Ma --- sound/soc/amd/acp/acp-sdw-legacy-mach.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/amd/acp/acp-sdw-legacy-mach.c b/sound/soc/amd/acp/acp-sdw-legacy-mach.c index 09b475c83c496..e8b6819cc4b45 100644 --- a/sound/soc/amd/acp/acp-sdw-legacy-mach.c +++ b/sound/soc/amd/acp/acp-sdw-legacy-mach.c @@ -303,13 +303,14 @@ static int create_sdw_dailink(struct snd_soc_card *card, static int create_sdw_dailinks(struct snd_soc_card *card, struct snd_soc_dai_link **dai_links, int *be_id, - struct asoc_sdw_dailink *soc_dais, + struct asoc_sdw_dailink *soc_dais, int num_dais, struct snd_soc_codec_conf **codec_conf) { struct device *dev = card->dev; struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card); struct amd_mc_ctx *amd_ctx = (struct amd_mc_ctx *)ctx->private; struct snd_soc_dai_link_component *sdw_platform_component; + int i; int ret; sdw_platform_component = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component), @@ -329,7 +330,7 @@ static int create_sdw_dailinks(struct snd_soc_card *card, } /* generate DAI links by each sdw link */ - while (soc_dais->initialised) { + for (i = 0; i < num_dais && soc_dais->initialised; i++) { int current_be_id = 0; ret = create_sdw_dailink(card, soc_dais, dai_links, @@ -463,7 +464,7 @@ static int soc_card_dai_links_create(struct snd_soc_card *card) /* SDW */ if (sdw_be_num) { ret = create_sdw_dailinks(card, &dai_links, &be_id, - soc_dais, &codec_conf); + soc_dais, num_ends, &codec_conf); if (ret) return ret; } -- 2.43.0