From a2ab293b581a057def57aa08e2f720c975d46caa Mon Sep 17 00:00:00 2001 From: Yingyuan Zhu Date: Wed, 29 Aug 2018 19:38:09 +0800 Subject: [PATCH] touchscreen: goodix_gt9xx: fix coverity warning PD#172713: touchscreen: goodix_gt9xx: fix coverity warning 1.The return value of function "gtp_i2c_read" is not checked in the "gt9xx.c" file. 2."ts"null pointer dereferencing reference in the "gt9xx.c" file. 3.In the "goodix_tool.c" file, because the third argument to "memset" function is of type int, expression "cmd_head.data_len + 1" is of type u16, so it need to convert to int. This causes "Unused value". Change-Id: I85ae8d9c11da0ed5d0ffbef97ad4b6c89fd78cf3 Signed-off-by: Yingyuan Zhu --- .../input/touchscreen/goodix_gt9xx/goodix_tool.c | 2 +- .../amlogic/input/touchscreen/goodix_gt9xx/gt9xx.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/amlogic/input/touchscreen/goodix_gt9xx/goodix_tool.c b/drivers/amlogic/input/touchscreen/goodix_gt9xx/goodix_tool.c index 4a1b2256fef3..49e23f9c630c 100644 --- a/drivers/amlogic/input/touchscreen/goodix_gt9xx/goodix_tool.c +++ b/drivers/amlogic/input/touchscreen/goodix_gt9xx/goodix_tool.c @@ -487,7 +487,7 @@ ssize_t goodix_tool_write(struct file *filp, const char __user *buff, size_t len { show_len = 0; total_len = 0; - memset(cmd_head.data, 0, cmd_head.data_len + 1); + memset(cmd_head.data, 0, (int)(cmd_head.data_len + 1)); memcpy(cmd_head.data, &buff[CMD_HEAD_LENGTH], cmd_head.data_len); if (FAIL == gup_update_proc((void*)cmd_head.data)) diff --git a/drivers/amlogic/input/touchscreen/goodix_gt9xx/gt9xx.c b/drivers/amlogic/input/touchscreen/goodix_gt9xx/gt9xx.c index 89bb5a03d8a2..7184e971d3be 100644 --- a/drivers/amlogic/input/touchscreen/goodix_gt9xx/gt9xx.c +++ b/drivers/amlogic/input/touchscreen/goodix_gt9xx/gt9xx.c @@ -754,6 +754,11 @@ static void goodix_ts_work_func(struct work_struct *work) u8 buf[8 * GTP_MAX_TOUCH] = {(GTP_READ_COOR_ADDR + 10) >> 8, (GTP_READ_COOR_ADDR + 10) & 0xff}; ret = gtp_i2c_read(ts->client, buf, 2 + 8 * (touch_num - 1)); + if (ret < 0) + { + GTP_ERROR("GTP read data from i2c slave device failed"); + return; + } memcpy(&point_data[12], &buf[2], 8 * (touch_num - 1)); } @@ -2633,8 +2638,11 @@ static int goodix_ts_remove(struct i2c_client *client) GTP_INFO("GTP driver removing..."); i2c_set_clientdata(client, NULL); - input_unregister_device(ts->input_dev); - kfree(ts); + if (ts) + { + input_unregister_device(ts->input_dev); + kfree(ts); + } if (goodix_wq) destroy_workqueue(goodix_wq);