From a219fb4db3a4577abcde7d64998d99c0cb13fd8c Mon Sep 17 00:00:00 2001 From: Xiaoyu Ye Date: Tue, 15 Jan 2019 15:49:59 -0800 Subject: [PATCH] ASoC: msm: qdsp6v2: add range check for audio port index Add range check to make sure the received audio port index from ADSP is within the valid range. Change-Id: Ief647df1659f7f349a843f666d8f92f34a9a43be Signed-off-by: Xiaoyu Ye --- sound/soc/msm/qdsp6v2/q6asm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/msm/qdsp6v2/q6asm.c b/sound/soc/msm/qdsp6v2/q6asm.c index c81dcc51200f..3e27f2e61e0d 100644 --- a/sound/soc/msm/qdsp6v2/q6asm.c +++ b/sound/soc/msm/qdsp6v2/q6asm.c @@ -1429,6 +1429,13 @@ static int32_t q6asm_srvc_callback(struct apr_client_data *data, void *priv) } dir = (data->token & 0x0F); + if (dir != IN && dir != OUT) { + pr_err("%s: Invalid audio port index: %d\n", __func__, dir); + if ((sid > 0 && sid <= SESSION_MAX)) + spin_unlock_irqrestore( + &(session[sid].session_lock), flags); + return 0; + } port = &ac->port[dir]; switch (data->opcode) {