From e59d3158a0f24e08a7f6b5bc820479b7676dddab Mon Sep 17 00:00:00 2001 From: Vignesh Kulothungan Date: Wed, 10 Oct 2018 14:19:59 -0700 Subject: [PATCH] asoc: add limit checks for copp index Check the validity of copp index before calling adm_close. This avoids redundant error logs in adm_close. CRs-Fixed: 2330388 Change-Id: I0b1cef5a45298fe9cbc84d9b944f6f10cec562df Signed-off-by: Vignesh Kulothungan --- asoc/msm-pcm-routing-v2.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index ab07d7ec9bc0..66d6c9b36076 100644 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -1926,6 +1926,12 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set) if (test_bit(idx, &copp)) break; + if (idx >= MAX_COPPS_PER_PORT) { + pr_debug("%s: copp idx is invalid, exiting\n", + __func__); + mutex_unlock(&routing_lock); + return; + } port_id = msm_bedais[reg].port_id; topology = adm_get_topology_for_port_copp_idx(port_id, idx); @@ -22872,6 +22878,12 @@ static int msm_pcm_routing_close(struct snd_pcm_substream *substream) for (idx = 0; idx < MAX_COPPS_PER_PORT; idx++) if (test_bit(idx, &copp)) break; + + if (idx >= MAX_COPPS_PER_PORT) { + pr_debug("%s: copp idx is invalid, exiting\n", + __func__); + continue; + } fdai->be_srate = bedai->sample_rate; port_id = bedai->port_id; topology = adm_get_topology_for_port_copp_idx(port_id,