From patchwork Mon Dec 4 12:42:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 173277 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2732590vqy; Mon, 4 Dec 2023 04:42:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3EflRU/RGAtOI42jWaDJaG3tK5dFNlj13sb0fffELEBwdV75b0Thj3Y8+TywKV8z48Pgb X-Received: by 2002:a17:903:22c4:b0:1cf:c929:d681 with SMTP id y4-20020a17090322c400b001cfc929d681mr1593959plg.60.1701693741957; Mon, 04 Dec 2023 04:42:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701693741; cv=none; d=google.com; s=arc-20160816; b=m6IuLVhasIEJHV6El2ilf5Yxe/hw3u8eEMkGsEt95fiwWblVGEBVCvHzi1n7aQxVo6 lykzIzedx0+tH1dEuJbJNkU53sKOsB7P+68KBOr3RahyIaVkPfzFNt/L8d9sROa2JwY7 Sf2Pr92b0zrm55Jb5wLNvgN1pOlTTfYCGTnbznWqhx/ambBHLatLisnOqIrexYRxnlmG qscrm46WxSx28fgXQrfxhcbwb23oUX5Q8oSrqyjVeEAhvOcXq4qE5Giy84ejg7our82O FxyNIma4tIWNrpPlC/5ZdMnQ41aJDHEW2TAntGtWeXEgoJWejrPdZQ1ozzxNfUp4zxNS L+QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=8x1dwoG6L6bxEjQMrtyUOBz/l2kp09gC7Z8V8HJ6Bn8=; fh=UxPRS3QCDLsgy4AtuqtGus0sz9Qskcz+mbkIPSU3++U=; b=rNuK1zRcLYGNVHqlRSrB3UP65fmarZmDJz4K7K45zbQy9K9eiB67T/1TlPE7d1/sJS 78I4SJE0fm1OFoY+mmezrPvzvYWsQLRu+y6vaAUWMBJ8ZHZ7AqoPw7gR1dI+SINGLlD4 ptbdsUFezQYueX0slSH+f2Vt+CRHj9uGiCJJQJMJIK+UZQ6aav+K8+vPVSa7LiE5pXSW UTYG/DSwlPOIo2moysfa+pdCxA++79+nMCEb3wbrX7d2ndQs1r2t5U8NDbTeBj9ZSoQK xcOkE4NCDQQn3gnf9ZeZUSwtJK196LdDJo/PHZfKbyvAEJYuRee9M21WxjHJwQB7Cg03 /Rgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YeJdh5ni; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id b14-20020a170902b60e00b001cf5cc3029fsi7460608pls.548.2023.12.04.04.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 04:42:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YeJdh5ni; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id A9F97805F2C8; Mon, 4 Dec 2023 04:42:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232380AbjLDMmH (ORCPT + 99 others); Mon, 4 Dec 2023 07:42:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbjLDMmG (ORCPT ); Mon, 4 Dec 2023 07:42:06 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8959DA7 for ; Mon, 4 Dec 2023 04:42:12 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40c09ba723eso13221275e9.2 for ; Mon, 04 Dec 2023 04:42:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701693731; x=1702298531; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=8x1dwoG6L6bxEjQMrtyUOBz/l2kp09gC7Z8V8HJ6Bn8=; b=YeJdh5ninM2QKZaPuVPWZQmau+UpYLchO5pRNMvWiqah6VlX8oIkPhEmnYGu+lB2Cl NEAXs2rQgLxS8nZf7dlAI2ZRbK1P68ikmj3ENClssaG4eFh23I0jgUtNkLp5yCqtIZ3B QxQpBab32f5e3YX946VrLRInUmkOgzktWhAvlF+FOOgyGWxn6zYlXGRsh7tcKlrRvj/t bQ3Ec6dqYSEmbNTFtavFTN5079EbMRvJl52WYyOW6H5OW3oLUcmsBhFgNbibFgVJnjyo zZMYlLvomHgKZgx09JUHaIyA2Wfu1b8WgSZ5up6uqgweSZMWRT60g7V3r0wGwtwvfspR 1xPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701693731; x=1702298531; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8x1dwoG6L6bxEjQMrtyUOBz/l2kp09gC7Z8V8HJ6Bn8=; b=N+CnQu2+seiAIPVs9SInd0lY1HvjUwHOe5d3lY6jAAlnkJehiEySEKBA8+gPDHG/Vv y+niPW2K/PUYLRbKoY1De8SEHtkXeQl94fBh+J971948QfsC19IeLS3Ujb4MTg1kDZMP d5Npqvf2EIcjPpJMdVNBpMtEhCaecLmtKO6cL5nWDeXRWKwYu3Pmi29ly37mUxNItHWO 0T9HbfMCFgF4CC032Y2SacHUxP1cL3DS5qJQKZJC1a/4S61n2ogNTyRA56CM7Tw61I0f h06tfCL8MAh4zD+ANEnJj6FD1IVwnh8iMRWXhcJswEuFHibmGWqeho9F75r3KnYSPlEe HisA== X-Gm-Message-State: AOJu0YwJxCs/e3xIq0pPEK+4+5V86lvv6XeZ2Oe52IT6vP9Yjd9asXAg tUlf1/+ThkSdknC7z0ZyvvSfpg== X-Received: by 2002:a05:600c:450f:b0:40a:5c71:2c3e with SMTP id t15-20020a05600c450f00b0040a5c712c3emr2172252wmo.19.1701693731047; Mon, 04 Dec 2023 04:42:11 -0800 (PST) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id f18-20020a05600c155200b004094d4292aesm14959419wmg.18.2023.12.04.04.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 04:42:10 -0800 (PST) Date: Mon, 4 Dec 2023 15:42:07 +0300 From: Dan Carpenter To: Kuninori Morimoto Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Rob Herring , Charles Keepax , Uwe =?iso-8859-1?q?Kleine-K?= =?iso-8859-1?q?=F6nig?= , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] ASoC: audio-graph-card2: fix off by one in graph_parse_node_multi_nm() Message-ID: <1032216f-902f-48f9-aa49-9d5ece8e87f2@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 04 Dec 2023 04:42:17 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784355217272777166 X-GMAIL-MSGID: 1784355217272777166 The > comparison should be >= to avoid writing one element beyond the end of the dai_link->ch_maps[] array. The dai_link->ch_maps[] array is allocated in graph_parse_node_multi() and it has "nm_max" elements. Fixes: e2de6808df4a ("ASoC: audio-graph-card2: add CPU:Codec = N:M support") Signed-off-by: Dan Carpenter Acked-by: Kuninori Morimoto --- In this same function I was also concerned about these conditions: if (cpu_idx > dai_link->num_cpus) if (codec_idx > dai_link->num_codecs) But I wasn't able to see out how those idx variables are actually used. sound/soc/generic/audio-graph-card2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index d9e10308a508..78d9679decda 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -557,7 +557,7 @@ static int graph_parse_node_multi_nm(struct snd_soc_dai_link *dai_link, struct device_node *mcodec_port; int codec_idx; - if (*nm_idx > nm_max) + if (*nm_idx >= nm_max) break; mcpu_ep_n = of_get_next_child(mcpu_port, mcpu_ep_n);