OSDN Git Service

input: touchscreen: Fix uninitialized variable usage in Atmel driver
authorVenkata Prahlad Valluru <vvalluru@codeaurora.org>
Tue, 13 Mar 2018 11:16:02 +0000 (16:46 +0530)
committerGerrit - the friendly Code Review server <code-review@localhost>
Wed, 14 Mar 2018 03:53:50 +0000 (20:53 -0700)
Initialize variables that are passed by reference, so that
they can be used safely afterwards, irrespective of the
called function actions.

Change-Id: Ib52c1cbc621913b21eb9520d305327ff5fd154fe
Signed-off-by: Venkata Prahlad Valluru <vvalluru@codeaurora.org>
drivers/input/touchscreen/atmel_maxtouch_ts.c

index 9aa57c1..712a278 100644 (file)
@@ -1473,7 +1473,7 @@ static int mxt_t6_command(struct mxt_data *data, u16 cmd_offset,
                          u8 value, bool wait)
 {
        u16 reg;
-       u8 command_register;
+       u8 command_register = 0;
        int timeout_counter = 0;
        int ret;
 
@@ -1578,7 +1578,7 @@ static int mxt_check_retrigen(struct mxt_data *data)
 {
        struct i2c_client *client = data->client;
        int error;
-       int val;
+       int val = 0;
 
        if (data->pdata->irqflags & IRQF_TRIGGER_LOW)
                return 0;
@@ -1623,9 +1623,11 @@ static int mxt_update_t100_resolution(struct mxt_data *data)
        struct i2c_client *client = data->client;
        int error;
        struct mxt_object *object;
-       u16 range_x, range_y, temp;
-       u8 cfg, tchaux;
-       u8 aux;
+       u16 range_x = 0;
+       u16 range_y = 0;
+       u16 temp;
+       u8 cfg = 0;
+       u8 tchaux, aux;
        bool update = false;
 
        object = mxt_get_object(data, MXT_TOUCH_MULTITOUCHSCREEN_T100);
@@ -1664,10 +1666,6 @@ static int mxt_update_t100_resolution(struct mxt_data *data)
        if (range_x == 0)
                range_x = 1023;
 
-       /* Handle default values */
-       if (range_x == 0)
-               range_x = 1023;
-
        if (range_y == 0)
                range_y = 1023;
 
@@ -1739,8 +1737,8 @@ static int mxt_update_t9_resolution(struct mxt_data *data)
 {
        struct i2c_client *client = data->client;
        int error;
-       struct t9_range range;
-       unsigned char orient;
+       struct t9_range range = {0};
+       unsigned char orient = 0;
        struct mxt_object *object;
        u16 temp;
        bool update = false;