From 35a6b7fa1d9bb6c204c5641fc98db27d359f31f1 Mon Sep 17 00:00:00 2001 From: Yingyuan Zhu Date: Wed, 29 Aug 2018 19:07:23 +0800 Subject: [PATCH] touchscreen: goodix_gt1x: fix coverity warning PD#172714: touchscreen: goodix_gt1x: fix coverity warning 1.The return value of the function "gt1x_i2c_read" is not checked in the "gt1x_generic.c" file. 2.There is no exit condition for the "while (retry > 0)" loop statement in the "gt1x_update.c" file. This causes "Untrusted valued as argument" and "Logically dead code". Change-Id: I07c0639d084ca3b961dd187ce6721f0167b2e4cc Signed-off-by: Yingyuan Zhu --- .../amlogic/input/touchscreen/goodix_gt1x/gt1x_generic.c | 6 ++++-- drivers/amlogic/input/touchscreen/goodix_gt1x/gt1x_update.c | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/amlogic/input/touchscreen/goodix_gt1x/gt1x_generic.c b/drivers/amlogic/input/touchscreen/goodix_gt1x/gt1x_generic.c index d1ba7b88204e..cbb9367c67b0 100644 --- a/drivers/amlogic/input/touchscreen/goodix_gt1x/gt1x_generic.c +++ b/drivers/amlogic/input/touchscreen/goodix_gt1x/gt1x_generic.c @@ -106,7 +106,7 @@ static ssize_t gt1x_debug_read_proc(struct file *file, char __user * page, size_ { char *ptr = page; char temp_data[GTP_CONFIG_MAX_LENGTH] = { 0 }; - int i; + int i, ret = -1; if (*ppos) { return 0; @@ -136,7 +136,9 @@ static ssize_t gt1x_debug_read_proc(struct file *file, char __user * page, size_ /* Touch PID & VID */ ptr += sprintf(ptr, "==== GT1X Version Info ====\n"); - gt1x_i2c_read(GTP_REG_VERSION, temp_data, 12); + ret = gt1x_i2c_read(GTP_REG_VERSION, temp_data, 12); + if (ret < 0) + return ret; ptr += sprintf(ptr, "ProductID: GT%c%c%c%c\n", temp_data[0], temp_data[1], temp_data[2], temp_data[3]); ptr += sprintf(ptr, "PatchID: %02X%02X\n", temp_data[4], temp_data[5]); ptr += sprintf(ptr, "MaskID: %02X%02X\n", temp_data[7], temp_data[8]); diff --git a/drivers/amlogic/input/touchscreen/goodix_gt1x/gt1x_update.c b/drivers/amlogic/input/touchscreen/goodix_gt1x/gt1x_update.c index b3de6b6ec123..cb9415087e69 100644 --- a/drivers/amlogic/input/touchscreen/goodix_gt1x/gt1x_update.c +++ b/drivers/amlogic/input/touchscreen/goodix_gt1x/gt1x_update.c @@ -515,6 +515,7 @@ int gt1x_update_prepare(char *filename) retry = 5; while (retry > 0) { + retry--; update_info.buffer = (u8 *) kzalloc(1024 * 4, GFP_KERNEL); if (update_info.buffer == NULL) { GTP_ERROR("Alloc %d bytes memory fail.", 1024 * 4);