summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarthikeyan Mani <kmani@codeaurora.org>2017-07-03 15:47:31 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2017-09-18 14:25:47 -0700
commitba3c2fde9879c8d3ec77b42c650e0bc9757cbaf2 (patch)
tree3dd5ccafa0274174d9a961646ceb597492a9afd3
parent6f777b2385c98a17d69bbeead6edbc7ad7470f72 (diff)
ASoC: wcd-dsp-mgr: Add range check before getting component
Add range check for wdsp_cmpnt_type to be within max and greater than 0 before accessing the array to get the component. CRs-fixed: 2068865 Change-Id: Ibc3128297a024f7d6d548c946a035e604f573b64 Signed-off-by: Karthikeyan Mani <kmani@codeaurora.org>
-rw-r--r--sound/soc/codecs/wcd-dsp-mgr.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sound/soc/codecs/wcd-dsp-mgr.c b/sound/soc/codecs/wcd-dsp-mgr.c
index 1613c5baa9c7..f995bf22c1c3 100644
--- a/sound/soc/codecs/wcd-dsp-mgr.c
+++ b/sound/soc/codecs/wcd-dsp-mgr.c
@@ -25,7 +25,8 @@
static char *wdsp_get_cmpnt_type_string(enum wdsp_cmpnt_type);
/* Component related macros */
-#define WDSP_GET_COMPONENT(wdsp, x) (&(wdsp->cmpnts[x]))
+#define WDSP_GET_COMPONENT(wdsp, x) ((x >= WDSP_CMPNT_TYPE_MAX || x < 0) ? \
+ NULL : (&(wdsp->cmpnts[x])))
#define WDSP_GET_CMPNT_TYPE_STR(x) wdsp_get_cmpnt_type_string(x)
/*