Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1332546rdb; Wed, 6 Dec 2023 16:06:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEm4y98AWzrNS2z1pJ65l2cFeOtKZncoB3sxQSOeOmiPDfwCKB0foJ7DOGN969YlZP+e/xQ X-Received: by 2002:a05:6a20:1445:b0:18f:97c:6151 with SMTP id a5-20020a056a20144500b0018f097c6151mr1992372pzi.78.1701907583287; Wed, 06 Dec 2023 16:06:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701907583; cv=none; d=google.com; s=arc-20160816; b=EFCNe/Sy1IO/gWWLvr/ym03jvfpYQP/fmGTzgJsTO/hwFxddngxrg8t3Qf0zd/37B3 2cGrbOjkInaM4n/hC88aMOmQs42jbKPAUo9XeEczsYytsImGfxt69ndlYoV5xdzafN80 ucEpB69cmU38OGJ0CbJ6BXemTVgGQAqlC9TuqBwHuifUt2zKbo/fPM359pLPWOZLHsQc haaqw1B5Cn+H7mZK22wAP22ntKcGtg8pyuWiiTNFFlmdgu/PdkBKMT3N/vTUlUNPRHNj zUDQ1CWLx9coh+0ow18e64eTsWrN7Oblp+8DkeOrGgmbs4PpUtt5iTA6yOsVtlbTcH/B k2ow== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VroMx0/6CiBxEEbP0IZM3e/f94aouNuIXqZi02L7qWw=; fh=zySoyVfK/7ExaDz2MWyww8poQ40q3tZak5TTvfb/Ovc=; b=vrtU0wNc4MZiTd7BGJg9hC7APyK9wPWUav1f+f8wkM8FPNzN4JSj9C5YVjOPIrVae8 ATJK9udbUvayk1J+WB6XmjipvdHvs11kqljFXajSO6MJ8uLTU6dGKk4B13cUymDwcy68 s8X/nCc/BXuRJbpA8Z/dLfTNCVlElhV3vvJbYCP+1u9bJtM40Rzd+XjlETM+Jv9Ef6CQ dT2IdMqXHtiN0yt2Z1krmjPkceTOEOC1K38c2MfKeTT/Cu5NBBghaz1SFBYSQvltSx8U nVmRlo3QA9NFf6fN9hQCCsASpM1P/0VnKoXgnaIlNAsG6sNc9qqHC9TqKAZEFFTbQBXd SUdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=irl.hu Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id j31-20020a63595f000000b005bdbcf7c446si126923pgm.171.2023.12.06.16.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 16:06:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=irl.hu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 057DC807F959; Wed, 6 Dec 2023 16:05:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441805AbjLGAE5 (ORCPT + 99 others); Wed, 6 Dec 2023 19:04:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232538AbjLGAEm (ORCPT ); Wed, 6 Dec 2023 19:04:42 -0500 Received: from irl.hu (irl.hu [95.85.9.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92F17D53 for ; Wed, 6 Dec 2023 16:04:38 -0800 (PST) Received: from fedori.lan (51b690cd.dsl.pool.telekom.hu [::ffff:81.182.144.205]) (AUTH: CRAM-MD5 soyer@irl.hu, ) by irl.hu with ESMTPSA id 00000000000716E7.0000000065710C14.001190BA; Thu, 07 Dec 2023 01:04:36 +0100 From: Gergo Koteles To: Shenghao Ding , Kevin Lu , Baojun Xu , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Gergo Koteles Subject: [PATCH 10/16] ASoC: tas2781: check negative indexes Date: Thu, 7 Dec 2023 01:04:26 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Mime-Autoconverted: from 8bit to 7bit by courier 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=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 howler.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 (howler.vger.email [0.0.0.0]); Wed, 06 Dec 2023 16:05:17 -0800 (PST) Negative indexes are not valid here. Signed-off-by: Gergo Koteles --- sound/soc/codecs/tas2781-fmwlib.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/tas2781-fmwlib.c b/sound/soc/codecs/tas2781-fmwlib.c index 20dc2df034e9..aa5f56f9ad33 100644 --- a/sound/soc/codecs/tas2781-fmwlib.c +++ b/sound/soc/codecs/tas2781-fmwlib.c @@ -2198,21 +2198,21 @@ int tasdevice_select_tuningprm_cfg(void *context, int prm_no, goto out; } - if (cfg_no >= tas_fmw->nr_configurations) { + if (cfg_no < 0 || cfg_no >= tas_fmw->nr_configurations) { dev_err(tas_priv->dev, "%s: cfg(%d) is not in range of conf %u\n", __func__, cfg_no, tas_fmw->nr_configurations); goto out; } - if (prm_no >= tas_fmw->nr_programs) { + if (prm_no < 0 || prm_no >= tas_fmw->nr_programs) { dev_err(tas_priv->dev, "%s: prm(%d) is not in range of Programs %u\n", __func__, prm_no, tas_fmw->nr_programs); goto out; } - if (rca_conf_no >= rca->ncfgs || rca_conf_no < 0 || + if (rca_conf_no < 0 || rca_conf_no >= rca->ncfgs || !cfg_info) { dev_err(tas_priv->dev, "conf_no:%d should be in range from 0 to %u\n", @@ -2304,7 +2304,7 @@ int tasdevice_prmg_load(void *context, int prm_no) goto out; } - if (prm_no >= tas_fmw->nr_programs) { + if (prm_no < 0 || prm_no >= tas_fmw->nr_programs) { dev_err(tas_priv->dev, "%s: prm(%d) is not in range of Programs %u\n", __func__, prm_no, tas_fmw->nr_programs); @@ -2349,7 +2349,7 @@ int tasdevice_prmg_calibdata_load(void *context, int prm_no) goto out; } - if (prm_no >= tas_fmw->nr_programs) { + if (prm_no < 0 || prm_no >= tas_fmw->nr_programs) { dev_err(tas_priv->dev, "%s: prm(%d) is not in range of Programs %u\n", __func__, prm_no, tas_fmw->nr_programs); -- 2.43.0