From patchwork Tue Mar 9 10:16:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 396804 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBC60C433DB for ; Tue, 9 Mar 2021 10:18:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 545FB64EF0 for ; Tue, 9 Mar 2021 10:18:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 545FB64EF0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D90C617D3; Tue, 9 Mar 2021 11:17:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D90C617D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615285083; bh=HH2x5oels53ssIUxm/YoXzgch96H6KJtMoW5DdDY0mU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ep+eDXesgoMGsISQ1MJ5utRYiHvJa5Oi8Q82LYMFblWFKvS7BTVBgheQ7+fIS5KR2 5mshGIN41k2eSGAXGp9GHfRfORjj7DoT9oMdENBFwiViwJSyAW/BleEr4tgqqVh1fW fHMG5VUwh3+2n8UgCpJsZbJuXX3IZb70rT4dWqo0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 808E7F8019B; Tue, 9 Mar 2021 11:16:25 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 286E4F80227; Tue, 9 Mar 2021 11:16:24 +0100 (CET) Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B2A1AF80166 for ; Tue, 9 Mar 2021 11:16:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B2A1AF80166 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iUEr5zGc" Received: by mail-wm1-x332.google.com with SMTP id y124-20020a1c32820000b029010c93864955so5568687wmy.5 for ; Tue, 09 Mar 2021 02:16:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7SC3b5p8KCrikFDvbH6RkupntFDK0hUEiUc11Ocw6b0=; b=iUEr5zGceE8+/7/m0L48oYW6R+wRzRzdZyKswX3XC7nqAOveY6c5JXSRotZGpPCYmW 7BzzSUj07puMvOdkaYigM6brsgxXhFTrHd2e0CAww5IWkMEoG/0XpMKahYzuLGybG+j5 X1IJxTBo6IsKVtEnFxHAtzT9zWKcSVFkyRgQBzI/jyqLnuSLUb4L8OxEX31eirYRgoPe m9MJGvzC7tD2DvUGh3PRk0ivlS4Q/Bt+Uf87m1qnumj+4RuFEn867Aq/KOAbsUvMSyaR jT4e8mMJyFmMEVHHy0mzFDJbix14iuCwcRUduaiosftVartrXFrGRrAdOFvJ81ocQI7p vu9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7SC3b5p8KCrikFDvbH6RkupntFDK0hUEiUc11Ocw6b0=; b=X64DiFi37EfWCqjRpqtPWNTpP62HKbVElX9F+xg7mKo2Ye4Az0lKzqifUMKKKF4yLr qFGGYQjS60bktzLEXgidzYvofpN8czskO5s+FP5f87+xtB6JYjGuui+IaPJYsozieurX TM5ClHvdqjZ9ca0UNFpcR+fmN1J+tfa/2dzhPDCNKtrl4qBpnGVzED2oqf1ACy3tMI+k nu2+hziKpGcgUiEBmr9fd8MJYMOXW6/R901mlybnr4PbNTyDQWx+84A1Dl5igGKM4F+I A7CGKD1RyvxgfZf1EzmiPM4JhsUm3lutyI9hDrvmHAJ4GsAUwGSbrgNBCmZGe5ogcSJ2 dN6w== X-Gm-Message-State: AOAM530iqulniqDyE+icJKhxIXdjtzlbXDPD3g2pjkGfTsSbsr5qTtHT Xi93Ng4y7OLQSR7vjMpvgLKRlw== X-Google-Smtp-Source: ABdhPJyjP9o7LviiwTh3yXCbAa9pkMn+bLirElNITQyZFrbR2RAgXQ8Tosz1vNZ68GAL66UEo2XgMQ== X-Received: by 2002:a05:600c:19d1:: with SMTP id u17mr3119882wmq.141.1615284976563; Tue, 09 Mar 2021 02:16:16 -0800 (PST) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id r2sm22552248wrt.8.2021.03.09.02.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 02:16:16 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH 1/3] ASoC: qcom: sdm845: Fix array out of bounds access Date: Tue, 9 Mar 2021 10:16:11 +0000 Message-Id: <20210309101613.25995-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210309101613.25995-1-srinivas.kandagatla@linaro.org> References: <20210309101613.25995-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: amit.pundir@linaro.org, alsa-devel@alsa-project.org, bjorn.andersson@linaro.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, john.stultz@linaro.org, Srinivas Kandagatla X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Static analysis Coverity had detected a potential array out-of-bounds write issue due to the fact that MAX AFE port Id was set to 16 instead of using AFE_PORT_MAX macro. Fix this by properly using AFE_PORT_MAX macro. Fixes: 1b93a8843147 ("ASoC: qcom: sdm845: handle soundwire stream") Reported-by: John Stultz Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/sdm845.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 6c2760e27ea6..1e2c2d0902ea 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -33,12 +33,12 @@ struct sdm845_snd_data { struct snd_soc_jack jack; bool jack_setup; - bool stream_prepared[SLIM_MAX_RX_PORTS]; + bool stream_prepared[AFE_PORT_MAX]; struct snd_soc_card *card; uint32_t pri_mi2s_clk_count; uint32_t sec_mi2s_clk_count; uint32_t quat_tdm_clk_count; - struct sdw_stream_runtime *sruntime[SLIM_MAX_RX_PORTS]; + struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; }; static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28}; From patchwork Tue Mar 9 10:16:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 396108 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBC0BC433E0 for ; Tue, 9 Mar 2021 10:18:09 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 185846525D for ; Tue, 9 Mar 2021 10:18:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 185846525D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9A20B17D2; Tue, 9 Mar 2021 11:17:17 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9A20B17D2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615285087; bh=VrnXP4MtdeQ1nxl+lr/neWZ6mFgIywwceu0F6yMpX9U=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bjj4SRlCTrUWOhwOIXeQXRn0APO4BrimWLlySeq9EO4z+FSjvQUUp5qbrOEi7tYS+ 40FHKrfFUg1WGYdnJ1eB1x8qbvDtxdDsRgCJJxnctMSwvJxdaXr6oHCd9HcBGCIivl GiyeJ9QPWnFzBzcaCmeFXkzZPiPqYSnXgHXdHSuM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4E370F8032B; Tue, 9 Mar 2021 11:16:27 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7AA21F8028B; Tue, 9 Mar 2021 11:16:25 +0100 (CET) Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E0B6EF8019B for ; Tue, 9 Mar 2021 11:16:17 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E0B6EF8019B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vN04cyxD" Received: by mail-wm1-x332.google.com with SMTP id f22-20020a7bc8d60000b029010c024a1407so5578700wml.2 for ; Tue, 09 Mar 2021 02:16:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WX5B3jn3ABsmJDUgiZ1eHo/S/aL6tIYdkt/tUOvK0TM=; b=vN04cyxDqUiaMClGFuacj9KHo6lA5Hfq2nxSH040ePyBd3FennWQC/tAWuSBtqUKE7 fVONhlsKroMNejjvUHSlU4t2OZRF8TZ02QMC0yzd03YUT8oIMkDz3piacSSLrAMJwvWI IdBM7MwXQNyuah+bClcd8A/K2Lshp7nmrFGc+pxsRocT8xic6mukCT/hWmYPkw9zqQ1d E8HIZopo3kjSFP02eBPu32hZ+L4KyLpEZw6iZENOBAmt0Cbj5rvQX9YlfpCKmqjHHthU lBdgmF2yf6/Af7s2TO9NBrx1URmr5QYNmmnzL1bs5abtJ07HAVF2N0wi/6jgtMqpx+16 PKzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WX5B3jn3ABsmJDUgiZ1eHo/S/aL6tIYdkt/tUOvK0TM=; b=PiTwarO0QfYntoVGpbsFJBHx+JSp5JyGAojV4lAedEGATUcfhBb3a/mEXF8WGM95DG /Vov8dUJ8wp7maVJPZT2FjKxyAXaXvkxqwdXePduTZWiFTtpCviUktZR6m0hJHmuZ0Pe nJ9gxwD+iBxg/TyHUVpL0VwB472AFhE20v52TAR4vJ7f+qScnxHtDSoRseYyG3EG4D0r VepzSG09OQ6qrYdppq3Vf+m275Vq5kAaEjCyI40+OLpzV5mEdLxuN/qVHsKCMCHytu0Z GNijC7SvnVGDUSejb4HUYH68JbcKIH3pAK0bIOwNI3PdyQ612v9h5PCq9oY7NsddAdHv iOcA== X-Gm-Message-State: AOAM531vtKjYHVOa+jmjaRG3yTPdRV0kI4D8sRwLR39PKGHshRwoSoGN McKYzyZ8fd3ribP7NfoBBjm//w== X-Google-Smtp-Source: ABdhPJy0TulbZb3A9b1N+k2CzwpgJACMjLIPJ6Slj0duc3bnYWnBDMNEy8FnmYKVFP+bv3j/XS90/A== X-Received: by 2002:a05:600c:2cb9:: with SMTP id h25mr3217369wmc.110.1615284977493; Tue, 09 Mar 2021 02:16:17 -0800 (PST) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id r2sm22552248wrt.8.2021.03.09.02.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 02:16:17 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH 2/3] ASoC: qcom: sdm845: Fix array out of range on rx slim channels Date: Tue, 9 Mar 2021 10:16:12 +0000 Message-Id: <20210309101613.25995-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210309101613.25995-1-srinivas.kandagatla@linaro.org> References: <20210309101613.25995-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: amit.pundir@linaro.org, alsa-devel@alsa-project.org, bjorn.andersson@linaro.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, john.stultz@linaro.org, Srinivas Kandagatla X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" WCD934x has only 13 RX SLIM ports however we are setting it as 16 in set_channel_map, this will lead to array out of bounds error! Orignally caught by enabling USBAN array out of bounds check: Fixes: 5caf64c633a3 ("ASoC: qcom: sdm845: add support to DB845c and Lenovo Yoga") Reported-by: John Stultz Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/sdm845.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 1e2c2d0902ea..153e9b2de0b5 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -27,7 +27,7 @@ #define SPK_TDM_RX_MASK 0x03 #define NUM_TDM_SLOTS 8 #define SLIM_MAX_TX_PORTS 16 -#define SLIM_MAX_RX_PORTS 16 +#define SLIM_MAX_RX_PORTS 13 #define WCD934X_DEFAULT_MCLK_RATE 9600000 struct sdm845_snd_data { From patchwork Tue Mar 9 10:16:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 396803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6E3EC433DB for ; Tue, 9 Mar 2021 10:18:55 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 076EE6525D for ; Tue, 9 Mar 2021 10:18:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 076EE6525D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 851A117EB; Tue, 9 Mar 2021 11:18:03 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 851A117EB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615285133; bh=92/Bf76YBPnMwhaF8nyS/2cw9CLb+nQUsb7on1K5pco=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ZYyDyjFhFt1zUoebdfnqztZn359zKT62LHeEFAtUc36knrsEX8/k1oxmqfIxC4ihg 4/7XtU/eDUFRwyh/9EfUNfV+yHWpZ/3Re5WnDs2w4pGzUXijW9BcDjMslImPs5d4Is x9SXSfI2HkfW2nQVeC2aend1qcqTn+vvQ//eHtnM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D8FA1F8042F; Tue, 9 Mar 2021 11:16:29 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4E457F8032C; Tue, 9 Mar 2021 11:16:27 +0100 (CET) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8C08DF8014E for ; Tue, 9 Mar 2021 11:16:18 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8C08DF8014E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pTzLXCk2" Received: by mail-wr1-x436.google.com with SMTP id u14so14593901wri.3 for ; Tue, 09 Mar 2021 02:16:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k2f0tZenESZ9YncapAA9EaDdy6imStpc0DvcSxZrmo4=; b=pTzLXCk2Aedtr6NwVfE+2EGGtQA16W6Rv+sGF8jMvDqFt94ESMP/AUGZvVpAf7bZ3g JtkOokCwXibCkC+NEMj+29fpFsHV9Z2voqM4sT8GARnoZOYWjNlWgzRavmZvPGpm85oX rOMjt+ZWdmMmmSfq/LxUa/1MgkYUlaLxEx4+6RyNSzUWXDMr6B3ZvlkuWkUiHNgS9I7/ +9A5fQi+jvfd93hADIQqfNSYG6LAY/YVqxRoWmcimPH/k/Gt96pR8wxtvsegKQKQPZCx CdeLpzHKpzuLweLG2kCx9LTSwgz/I0hW/4VuInPTTt4UDjbzVOxN/YgUeSIrBhcvNOMw Pd7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k2f0tZenESZ9YncapAA9EaDdy6imStpc0DvcSxZrmo4=; b=CKrsU+W0b2u1Cu6yKyedgFeJr+FTmHlO1SHbqyrXGVgxFH8K4c4PZi/IICD9KN3nex BXPHDYW4p2QzoAxNq7cxcr5NAWwKvmy7VbjFn+HInGKpDVlopl5Tl0lqOiDQvbJ7de6g hcCwUsQvn4qAuHN8ieyeMJ5IYyAkp70+8X7ybt5wM9qPaEKnvM9EJOYteTBNK5ykwLyp RIFnjXKkW+G6FGEvEi+92w2ESBnSRupN2CSXKOpaYU+L5z0cQOiGEekaT3Ox3P2zzMiu VGQlQHB7CN2mWscPMJcG1dDlAIAo2ANCkYquHIC3LggMfqRJOp6NmHEfcZDfwHye06Ru fcbg== X-Gm-Message-State: AOAM530FStOQeKPi2Hr7Lh7WqcsWhe9jhFRI8jyKa7BGn1qOCXrAgCuU Qf3MlvXTUF7ylhVSXPZM8Mgu9A== X-Google-Smtp-Source: ABdhPJysCEn7R3n1S1UKNF5EIYYLunM/WXcDB9bEOK2WFJAcZFx+M2y9CWDMkpxp9pAyr/BdErrlKQ== X-Received: by 2002:adf:fe09:: with SMTP id n9mr27607109wrr.104.1615284978392; Tue, 09 Mar 2021 02:16:18 -0800 (PST) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id r2sm22552248wrt.8.2021.03.09.02.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 02:16:18 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH 3/3] ASoC: codecs: wcd934x: add a sanity check in set channel map Date: Tue, 9 Mar 2021 10:16:13 +0000 Message-Id: <20210309101613.25995-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210309101613.25995-1-srinivas.kandagatla@linaro.org> References: <20210309101613.25995-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: amit.pundir@linaro.org, alsa-devel@alsa-project.org, bjorn.andersson@linaro.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, john.stultz@linaro.org, Srinivas Kandagatla X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" set channel map can be passed with a channel maps, however if the number of channels that are passed are more than the actual supported channels then we would be accessing array out of bounds. So add a sanity check to validate these numbers! Fixes: a61f3b4f476e ("ASoC: wcd934x: add support to wcd9340/wcd9341 codec") Reported-by: John Stultz Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/wcd934x.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c index 40f682f5dab8..1d27cdf5277d 100644 --- a/sound/soc/codecs/wcd934x.c +++ b/sound/soc/codecs/wcd934x.c @@ -1871,6 +1871,12 @@ static int wcd934x_set_channel_map(struct snd_soc_dai *dai, struct wcd934x_codec *wcd; int i; + if (tx_num > WCD934X_TX_MAX || rx_num > WCD934X_RX_MAX) { + dev_err(wcd->dev, "Invalid tx %d or rx %d channel count\n", + tx_num, rx_num); + return -EINVAL; + } + wcd = snd_soc_component_get_drvdata(dai->component); if (!tx_slot || !rx_slot) {