Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp365548imi; Thu, 21 Jul 2022 02:29:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1urxEECW0ilW9Hl/qtfxDV4ru0zb1zUgDLpbTUHHSDjyRbdlw/9xvLKzyfrQR4kGds1WSvg X-Received: by 2002:a63:5d44:0:b0:419:b8e8:962 with SMTP id o4-20020a635d44000000b00419b8e80962mr31222346pgm.326.1658395798898; Thu, 21 Jul 2022 02:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658395798; cv=none; d=google.com; s=arc-20160816; b=O5HfGoGj28JWsBt0INl0AbskjGsWMA9kH77axcOdbMR9A2TuUgJBrqZP857LUm0FMm 9/fVS1H9coCBfioierYUjXySOg55Ihi8npuYI7TqEE8qVpYp0UZwIcRvYQIyMEIQR5C1 DqDxKiaGC6uE9Hgo0l82cIvKe4kzRbyADK1wh5fWAlS6/VmbUT7tJIvVdufQaI9Y28jU WMDR9OHluCB/7Ltq51xcE4UZjOd6C2bPAFToPXVAkyq8nUG0XSJUdw04Bp2RK/OeY9v5 COxzxtwWe8quAIpz9xlpT6H9Os7j8cIXn/cw2gqyWkeKiHazqW9/JcPjS+LY05a7OT8R +MhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=uMKx3yo4qm2q5GXbbRBhw2rYCJ5pGTGFj+uJFBKB4oA=; b=jFYKHFQqg5A7oXETZGP1s3N0UiolZi9IvzoefLZPqqEvlWvgaBv//5FbpntOBHwvz/ ahX3RMSYbwS6BojD+NRtFjF/ERtO5455Pt2NX1SgHXHt/VxoVmFF9w2ycYM0CZk0HuLv 5iyrb4wOPpLbdNCX5z4mInlQLNWYr9HKT3QsO6yd2e0g2lMzefBCVW8B1c93av/eToDC OmPPm53LTauecePpuNpP26tuFUfbALzE2lXdLMZ/LiOYLbVolHS9k5uToYxpDhSMLO9M kKa1s43F9GahYilM7YVWSAwaXrrm13ddUAWGJ5NIeXiSCoPkwu0m5wYF72VEngY3MHOS /FPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jz19-20020a17090b14d300b001e3022c3e0bsi4938803pjb.30.2022.07.21.02.29.44; Thu, 21 Jul 2022 02:29:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232261AbiGUJCa (ORCPT + 99 others); Thu, 21 Jul 2022 05:02:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbiGUJC3 (ORCPT ); Thu, 21 Jul 2022 05:02:29 -0400 Received: from smtp.smtpout.orange.fr (smtp-24.smtpout.orange.fr [80.12.242.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC4542AC8 for ; Thu, 21 Jul 2022 02:02:28 -0700 (PDT) Received: from pop-os.home ([90.11.190.129]) by smtp.orange.fr with ESMTPA id ES4doiupgxFTAES4eoDEeb; Thu, 21 Jul 2022 11:02:26 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Thu, 21 Jul 2022 11:02:26 +0200 X-ME-IP: 90.11.190.129 From: Christophe JAILLET To: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , Banajit Goswami , alsa-devel@alsa-project.org Subject: [PATCH] ASoC: qcom: q6dsp: Fix an off-by-one in q6adm_alloc_copp() Date: Thu, 21 Jul 2022 11:02:22 +0200 Message-Id: <0fca3271649736053eb9649d87e1ca01b056be40.1658394124.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org find_first_zero_bit() returns MAX_COPPS_PER_PORT at max here. So 'idx' should be tested with ">=" or the test can't match. Fixes: 7b20b2be51e1 ("ASoC: qdsp6: q6adm: Add q6adm driver") Signed-off-by: Christophe JAILLET --- sound/soc/qcom/qdsp6/q6adm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/qcom/qdsp6/q6adm.c b/sound/soc/qcom/qdsp6/q6adm.c index 01f383888b62..1530e98df165 100644 --- a/sound/soc/qcom/qdsp6/q6adm.c +++ b/sound/soc/qcom/qdsp6/q6adm.c @@ -217,7 +217,7 @@ static struct q6copp *q6adm_alloc_copp(struct q6adm *adm, int port_idx) idx = find_first_zero_bit(&adm->copp_bitmap[port_idx], MAX_COPPS_PER_PORT); - if (idx > MAX_COPPS_PER_PORT) + if (idx >= MAX_COPPS_PER_PORT) return ERR_PTR(-EBUSY); c = kzalloc(sizeof(*c), GFP_ATOMIC); -- 2.34.1