dsp: asm: 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: Soumya Managoli <smanag@codeaurora.org>
diff --git a/dsp/q6asm.c b/dsp/q6asm.c
index e415db0..95bb8ed 100644
--- a/dsp/q6asm.c
+++ b/dsp/q6asm.c
@@ -1774,6 +1774,13 @@
 		return 0;
 	}
 
+	if (dir != IN && dir != OUT) {
+		pr_err("%s: Invalid audio port index: %d\n", __func__, dir);
+		if ((session_id > 0 && session_id <= SESSION_MAX))
+			spin_unlock_irqrestore(
+				&(session[session_id].session_lock), flags);
+			return 0;
+	}
 	port = &ac->port[dir];
 
 	switch (data->opcode) {