[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20210309101613.25995-4-srinivas.kandagatla@linaro.org>
Date: Tue, 9 Mar 2021 10:16:13 +0000
From: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
To: broonie@...nel.org
Cc: perex@...ex.cz, alsa-devel@...a-project.org,
linux-kernel@...r.kernel.org, lgirdwood@...il.com,
john.stultz@...aro.org, amit.pundir@...aro.org,
bjorn.andersson@...aro.org,
Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Subject: [PATCH 3/3] ASoC: codecs: wcd934x: add a sanity check in set channel map
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 <john.stultz@...aro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
---
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) {
--
2.21.0
Powered by blists - more mailing lists