Merge "diag: Prevent crash due to buffer over run" into msm-3.0
diff --git a/drivers/char/diag/diagfwd.c b/drivers/char/diag/diagfwd.c
index 74d2d71..d7191c8 100644
--- a/drivers/char/diag/diagfwd.c
+++ b/drivers/char/diag/diagfwd.c
@@ -903,6 +903,11 @@
 void diag_send_error_rsp(int index)
 {
 	int i;
+
+	if (index > 490) {
+		pr_err("diag: error response too huge, aborting\n");
+		return;
+	}
 	driver->apps_rsp_buf[0] = 0x13; /* error code 13 */
 	for (i = 0; i < index; i++)
 		driver->apps_rsp_buf[i+1] = *(driver->hdlc_buf+i);