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 2B2CC3783B5 for ; Thu, 28 May 2026 08:22:02 +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=1779956524; cv=none; b=XOWZZ/d7PBbM0elV2dVzXZdjNqy4CUjbYmtYB3/65kU7mmlWJ2XIA7E6CICbjnKSvKVDHwtfyEwun0e/VgH+nyDt/0OmSJb7hCW/R1GcVVi2IIYoy432ACKv5RbW7AVNdziGKxzbYLqWSKxTR3yk7HrN5HU9A/Ea3tsatkzA9fE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779956524; c=relaxed/simple; bh=fvj9ewGZjm9n7aBmJJ762YtuEVTNsjnkrzhk+PiVYzM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FUV8CBR8JPGSO1SLqxQjPEqloLOBE/UeN6vVWxkAjwUAm/ZAUusogQyj143N43DInzm3PuSByFvUioHhCtEPTpThAafIoqyjFpY2ULnpCRYToTXXw2rfUu6Ay+3woRBy4WbbJbcUNwDpnuV97VheU0SP0bU41Zq6RU+krMA+ekA= 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=DAtFUYTu; 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="DAtFUYTu" 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 CFC923F9C2 for ; Thu, 28 May 2026 08:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20251003; t=1779956520; bh=YjssOyZAjkfDJZNpMAdpNGPZCAwIg5gZnjT4sc3lUEU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DAtFUYTusMqzIXkCUHbuK04f2in8qieGKO8v9LwzqotjuwMGPytNtq1AR1nQEVK0A X6Dgf6+o/Bscs5W31PbRKSajVIEBxbuxn2+fHk547Lu7HrOZB/iV3XZ9j6woX/TcOP zKASqn5uGmxxL40R4cZHmrodmWArqDwIKACXEYhaRBRXk6B/SI0LZK03nCF9F3a2PI y/Nw9BJhtO9C5be9URu02slHm2f0zSDoQCP3ylFnDgqHW953eIlTjr11OlWFKgZQuW EIF3g4PfxldAFSQ0mATGZA0G6Eug7a7bKggfPnUOw+INHrjQ+b9qkry41cKfYv6Yq3 VNw3DMgWPzaTCEHivGOOIf6dwa1jw/ZX1a+q15qbkmU6dTPbuCgG4T9/+3N2auD0Zf A0/DU475+eElbH0Ib+vhKEgYi63+HfxO3tcR8GRrxrzXo9TsGKMSZpfIY7ZHtj2VmF WWmHmOa/iXUeb+ShlXbwEQD6pzH3lgQbPQoTLByI8Bg8ZeBppm7xsjfctAaso4lyDx vVSDkClTbt1Gkt1Bq3Ha+4xj/6STk15cnss/oX04/Ed+AUxaA9nobIHBUHYLZOETqv OcrB+NsGjl1HLOfo+qn0DUSWoGNRCeGoZ/wHdGrkuaeAVZxV0OvjUdHY/0EYDvJILX 5cuiGFwRgx93m6+vr4Av/9+Y= Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4905428aad6so43736705e9.1 for ; Thu, 28 May 2026 01:22:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779956520; x=1780561320; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=YjssOyZAjkfDJZNpMAdpNGPZCAwIg5gZnjT4sc3lUEU=; b=irai4aqXZpbg4FqJxIQwVVF5ON/clVdWC7i8zu55cjgV/S301S99q0rceC6q4SjFVc JhKHXlRPonZtH8glVGGG16OD/Ksho6wPSPC2WkqE36Ci5R+bmTbeymY901dQxFqkaQIP IYPzsQcVxx9V41dQyPkPd3bZBpTzxDXnSRqAENaFKu5hhGKpIVMxshiV42bHOgTUXqgY Bup2Vs6UyFDAwnrM05tkDa3rbqMGCRmxIH9mfz1gmofIfzM/BiKQOyDO5RPDchjYw7qE g55RWXHxQd22NmmbYGuLmBMV01i/WnGGnhfUHkUfSWLzpDavfP/O8c84Y1+ztI7qELiM 0uKw== X-Forwarded-Encrypted: i=1; AFNElJ+xNbpAuiYeOSjE8jgg+W1I+6MS9VPfR2QxdNdPeumoiiVFZpAI+D3jJcNtkvNLLlV770QTmZZf2ezQqoY=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3uy/tP5ZTid2SF2fWAQmjieRYv5THgml1FkzW26bz8eHOlK9w B7fqlygkbjef+8/L+Peu701SkayuOAMJ61DBWmv/vo1kgawaE5+mCY8FJ/AAXZQuE8pVkuwQdPM hismNTg2ki9Nj2wE385n2Ms6AWH69uuK9sTK4kq3b6xc9LoVIZpRct6BQV2yck0zk47/M0+zBOM MGRnOV1g== X-Gm-Gg: Acq92OEk9qX2IkKwzONdHadVe2+olL8rZ/zN5EWXMu3RNOarDYjWkbFhzXh3UpJi0k2 LjJKqWIYB+drtMpCxvlPsu9Vaf08B7/kwQY9hTnfDgUVQLHL80ngez7blBcW0a8yCNywGi+5O2k JlcfDFioKj4lgce3pSdP9AOh7XUaE49AnE4UvoFcnYF/F+Mye8Wl02n6dfEuqEYVavnEJJL9SOX 8mGaqw3t/Nn8Of8JQziHxgcrSDKoejrHqS+1WwWTXgF0GE8wnXkMxtFzRl0yj1h7/7HUl6MUlGs Xg4BP95VVW5KYUzQJXA8fllly8jvyxjgnGT9wGbX1AmUWM70QssnbN2M10Z8lU3VcIfQR+spAq2 +kvSaaEaH84htMCEBNWG9rOF8zdjJ+lekjitHVj9CA7y74a3tPYHo9lumB2SCuJz8CARrfUFmGZ w7DKdrr0Epvptl6AvBNoRCpjr1JPcPQw== X-Received: by 2002:a05:600d:644d:20b0:490:3cb4:f1b3 with SMTP id 5b1f17b1804b1-490426c5a3dmr314933005e9.16.1779956520306; Thu, 28 May 2026 01:22:00 -0700 (PDT) X-Received: by 2002:a05:600d:644d:20b0:490:3cb4:f1b3 with SMTP id 5b1f17b1804b1-490426c5a3dmr314932565e9.16.1779956519966; Thu, 28 May 2026 01:21:59 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 01:21:59 -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 2/2] ASoC: amd: acp-sdw-sof: Bound DAI link iteration Date: Thu, 28 May 2026 16:21:10 +0800 Message-ID: <20260528082110.915549-2-aaron.ma@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260528082110.915549-1-aaron.ma@canonical.com> References: <20260528082110.915549-1-aaron.ma@canonical.com> 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 sof_dais until it finds an entry with initialised cleared, but sof_dais is allocated with exactly num_ends entries. If all entries are initialised, the loop reads past the end of the array. Pass the allocated entry count to create_sdw_dailinks() and stop before reading past the array. Fixes: 6d8348ddc56e ("ASoC: amd: acp: refactor SoundWire machine driver code") Signed-off-by: Aaron Ma --- sound/soc/amd/acp/acp-sdw-sof-mach.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/amd/acp/acp-sdw-sof-mach.c b/sound/soc/amd/acp/acp-sdw-sof-mach.c index a0fd8a6f99708..a423853f3a97d 100644 --- a/sound/soc/amd/acp/acp-sdw-sof-mach.c +++ b/sound/soc/amd/acp/acp-sdw-sof-mach.c @@ -220,13 +220,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 *sof_dais, + struct asoc_sdw_dailink *sof_dais, int num_dais, struct snd_soc_codec_conf **codec_conf) { + int i; int ret; /* generate DAI links by each sdw link */ - while (sof_dais->initialised) { + for (i = 0; i < num_dais && sof_dais->initialised; i++) { int current_be_id = 0; ret = create_sdw_dailink(card, sof_dais, dai_links, @@ -334,7 +335,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) /* SDW */ if (sdw_be_num) { ret = create_sdw_dailinks(card, &dai_links, &be_id, - sof_dais, &codec_conf); + sof_dais, num_ends, &codec_conf); if (ret) return ret; } -- 2.43.0