From patchwork Mon Mar 22 12:26:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 406132 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3527365jai; Mon, 22 Mar 2021 05:33:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYo6DVeBiC0guNCORAQ8g0e69yUa201o/nBs17HxdUha3io5kXo7cXU3weqrk8lviq06qR X-Received: by 2002:a17:906:400b:: with SMTP id v11mr18951854ejj.194.1616416427616; Mon, 22 Mar 2021 05:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616416427; cv=none; d=google.com; s=arc-20160816; b=qBeWWXBhCnJxKGKDhaRu8j4wZplA7y9KB2pQl0TX+297nQ1o9A3cbHKg+2M+E6l1q2 QPN2gAo9oPFTXwzXpuB/7FuD3WUjoQGIm4GORObYPnO0IRkS+yNB6s8PInKbF/a4WtOM 5CEB4KVmeSOxRiZK56Tb9IEOIBI5HsSFzv4n045xu6zokgyfIvhlOvhbUbF0J0eoqe3k DZ9zah6ymjgjI9P8LICv62czBlwTlmEq/0ctJSgcIPKsjPXmnUWhCTSjV0uvnQ8JV31b STBOLOPzK/zBkPPpi7bKPLSxQfHQzbOhfI0+fC8SjDpCI0+fBJ2MIbHyZE1SjYrUQRcV 9rpQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ku74VOaUXC55rJpcIECP8tXIpORCv7zlO3AfhqBJAfQ=; b=eQyRkJ4PajKqF7lRA7Uq5U0YYqIzTxO7UnYdXv8SzaG6H8N8XnkWwj7LMQ3W4P53Eq +cNPSx3dqg53I0zl2UQus5855Tk8dM5Zh/GZW8wEq0vUIj+f+0cgFtnofIXl4pR67ss6 ypCqHCaZZb4XyM0GlIP3wbkMh3pvjiYEvCHc0WfXVwaJpWEPTJegARJJl5UKHGVRFm44 mt8x9uTt3HE3R10+9kbO5ajb8jBNKSd7c4AXWe7gtwF9LTptO9eWFOttpX03FTJhiRmB H/niFAzSkyztQ5/C/nIxVVCX/7NdQnfHhtPI1GTy+HPpBrVnqlO3v5EfXwSdslrARCCv Me2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YPmrwzRM; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si11105155edy.321.2021.03.22.05.33.47; Mon, 22 Mar 2021 05:33:47 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YPmrwzRM; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231157AbhCVMdX (ORCPT + 12 others); Mon, 22 Mar 2021 08:33:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:55266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbhCVMcY (ORCPT ); Mon, 22 Mar 2021 08:32:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E8A7E619A1; Mon, 22 Mar 2021 12:32:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1616416343; bh=yTayAIBKuIJn+gV5lv0TS3Hk7EPo/GlQvUqJXS22suA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YPmrwzRMsLUWPCmQqtqvG/svi1YZaG7JOlH9VjJgVttnxcwCYDgfc1mhAO88op1oz uLOo5OJ71vCu1u+f/gJsW4VhvsVPmFBUDVqEPMhE/gOCXHtD9+g0vh6TgUeLafl0aP IRJMjMMZcdZ7M9n4NSrbwYy1PGPjhp01N2ZgoQWE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Stultz , Srinivas Kandagatla , Mark Brown Subject: [PATCH 5.11 035/120] ASoC: codecs: wcd934x: add a sanity check in set channel map Date: Mon, 22 Mar 2021 13:26:58 +0100 Message-Id: <20210322121930.831408240@linuxfoundation.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210322121929.669628946@linuxfoundation.org> References: <20210322121929.669628946@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Srinivas Kandagatla commit 3bb4852d598f0275ed5996a059df55be7318ac2f upstream. 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 Link: https://lore.kernel.org/r/20210309142129.14182-4-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/codecs/wcd934x.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/sound/soc/codecs/wcd934x.c +++ b/sound/soc/codecs/wcd934x.c @@ -1873,6 +1873,12 @@ static int wcd934x_set_channel_map(struc wcd = snd_soc_component_get_drvdata(dai->component); + 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; + } + if (!tx_slot || !rx_slot) { dev_err(wcd->dev, "Invalid tx_slot=%p, rx_slot=%p\n", tx_slot, rx_slot);