Merge "asoc: Check backend index to apply channel map" into audio-drivers.lnx.2.0
diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c
index bab28d1..18d805e 100644
--- a/asoc/msm-pcm-routing-v2.c
+++ b/asoc/msm-pcm-routing-v2.c
@@ -17463,6 +17463,12 @@
uint32_t be_idx = ucontrol->value.integer.value[0];
int i;
+ if (be_idx < 0 || be_idx >= MSM_BACKEND_DAI_MAX) {
+ pr_err("%s: Invalid Backend ID %d\n",
+ __func__, be_idx);
+ return -EINVAL;
+ }
+
for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++) {
channel_map[i] = (char)(ucontrol->value.integer.value[i + 1]);
if (channel_map[i] > PCM_MAX_CHMAP_ID) {