summaryrefslogtreecommitdiff
path: root/asoc
diff options
context:
space:
mode:
authorShashi Kant Maurya <smaury@codeaurora.org>2021-02-23 17:30:16 +0530
committerLakshman Chaluvaraju <lchalu@codeaurora.org>2021-03-17 16:56:24 +0530
commite4c6762dbd22f4290839ce63165dccfbdaf4e9bc (patch)
tree1b5b581ddfcfd033c1a7d3bc4de0afb6ab3a343b /asoc
parent2531ff66b0391a5a44e1c58eccca039bc45363a4 (diff)
downloadmsm-extra-e4c6762dbd22f4290839ce63165dccfbdaf4e9bc.tar.gz
dsp: adm: add to check output/input channel
To avoid out of bound value of output/input channel add the check. Change-Id: I25b7616d6fc08c2d0bb530dfb1457471dc25861c Signed-off-by: Shashi Kant Maurya <smaury@codeaurora.org> Signed-off-by: Lakshman Chaluvaraju <lchalu@codeaurora.org>
Diffstat (limited to 'asoc')
-rw-r--r--asoc/msm-pcm-routing-v2.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c
index 7aafe2b9..99e93c39 100644
--- a/asoc/msm-pcm-routing-v2.c
+++ b/asoc/msm-pcm-routing-v2.c
@@ -1729,6 +1729,11 @@ static int msm_pcm_routing_channel_mixer(int fe_id, bool perf_mode,
for (i = 0; i < ADM_MAX_CHANNELS && channel_input[fe_id][i] > 0;
++i) {
be_id = channel_input[fe_id][i] - 1;
+ if (be_id < 0 || be_id >= MSM_BACKEND_DAI_MAX) {
+ pr_err("%s: Received out of bounds be_id %d\n",
+ __func__, be_id);
+ return -EINVAL;
+ }
channel_mixer[fe_id].input_channels[i] =
msm_bedais[be_id].channel;
@@ -3470,10 +3475,10 @@ static int msm_pcm_get_out_chs(struct snd_kcontrol *kcontrol,
static int msm_pcm_put_out_chs(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
- u16 fe_id = 0;
-
+ u16 fe_id = 0, out_ch = 0;
fe_id = ((struct soc_multi_mixer_control *)
kcontrol->private_value)->shift;
+ out_ch = ucontrol->value.integer.value[0];
if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) {
pr_err("%s: invalid FE %d\n", __func__, fe_id);
return -EINVAL;
@@ -3482,6 +3487,12 @@ static int msm_pcm_put_out_chs(struct snd_kcontrol *kcontrol,
pr_debug("%s: fe_id is %d, output channels = %d\n", __func__,
fe_id,
(unsigned int)(ucontrol->value.integer.value[0]));
+ if (out_ch < 0 ||
+ out_ch > ADM_MAX_CHANNELS) {
+ pr_err("%s: invalid output channel %d\n", __func__,
+ out_ch);
+ return -EINVAL;
+ }
channel_mixer[fe_id].output_channel =
(unsigned int)(ucontrol->value.integer.value[0]);