touch/ftm5: only handle touch events with valid touch IDs

Bug: 193366807
Test: Single touch manipulation
Test: Put 10 fingers on the screen and remove them 1 by 1.
Test: Press with 11 fingers and check if any error logs.
Signed-off-by: Tai Kuo <taikuo@google.com>
Change-Id: I9363d64d0e5e275b4e0ad2cbbfab6731b46f507e
diff --git a/ftm5/fts.c b/ftm5/fts.c
index b70c57a..5126b37 100644
--- a/ftm5/fts.c
+++ b/ftm5/fts.c
@@ -2963,6 +2963,12 @@
 
 	touchType = event[1] & 0x0F;
 	touchId = (event[1] & 0xF0) >> 4;
+	if (touchId >= TOUCH_ID_MAX) {
+		mutex_unlock(&info->input_report_mutex);
+		dev_err(info->dev, "%s : Invalid touch ID = %d ! No Report...\n",
+			__func__, touchId);
+		goto no_report;
+	}
 
 	x = (((int)event[3] & 0x0F) << 8) | (event[2]);
 	y = ((int)event[4] << 4) | ((event[3] & 0xF0) >> 4);
@@ -3112,6 +3118,12 @@
 
 	touchType = event[1] & 0x0F;
 	touchId = (event[1] & 0xF0) >> 4;
+	if (touchId >= TOUCH_ID_MAX) {
+		mutex_unlock(&info->input_report_mutex);
+		dev_err(info->dev, "%s : Invalid touch ID = %d ! No Report...\n",
+			__func__, touchId);
+		return false;
+	}
 
 	switch (touchType) {
 #ifdef STYLUS_MODE
@@ -4477,8 +4489,8 @@
 #ifndef SKIP_PRESSURE
 			if ((int)report->coords[i].pressure <= 0) {
 				dev_err(info->dev,
-					"%s: Pressure is %i, but pointer is not leaving.\n",
-					__func__, (int)report->coords[i].pressure);
+					"%s: Pressure is %i, but pointer %d is not leaving.\n",
+					__func__, (int)report->coords[i].pressure, i);
 			}
 			input_report_abs(info->input_dev, ABS_MT_PRESSURE,
 					 report->coords[i].pressure);