import PULS_20180308
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / input / touchscreen / mediatek / GT9XX_hotknot_fpga / goodix_tool.c
index 6ddac638d72f889a4d97368c5be8b800ed9da8b9..550268efdf0bc7c88343a1f757f146780fa547d7 100644 (file)
@@ -566,6 +566,13 @@ static s32 goodix_tool_write(struct file *filp, const char __user *buff, unsigne
     {
         show_len = 0;
         total_len = 0;
+               if ((cmd_head.data == NULL)
+                   || (cmd_head.data_len >= DATA_LENGTH)
+                   || (cmd_head.data_len >= (len - CMD_HEAD_LENGTH))) {
+                       GTP_ERROR("copy_from_user data out of range.");
+                       return -EINVAL;
+               }
+
         memset(cmd_head.data, 0, cmd_head.data_len + 1);
         memcpy(cmd_head.data, &buff[CMD_HEAD_LENGTH], cmd_head.data_len);
         GTP_DEBUG("update firmware, filename: %s", cmd_head.data);