aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/resistive-adc-touch.c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2021-06-05 16:09:36 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2021-06-05 16:41:08 -0700
commit6cdc1ef84eacca85642828840f2ec4f84130c9b6 (patch)
tree3ee7de258477ed057307af98037680ee7ab8a197 /drivers/input/touchscreen/resistive-adc-touch.c
parentInput: pm8941-pwrkey - add support for PMK8350 PON_HLOS PMIC peripheral (diff)
downloadlinux-dev-6cdc1ef84eacca85642828840f2ec4f84130c9b6.tar.xz
linux-dev-6cdc1ef84eacca85642828840f2ec4f84130c9b6.zip
Input: resistive-adc-touch - fix uninitialized variable 'press'
In the case where st->ch_map[GRTS_CH_PRESSURE] < GRTS_MAX_CHANNELS is false and also st->ch_map[GRTS_CH_Z1] < GRTS_MAX_CHANNELS is false the variable press is not initialized and contains garbage. In this situation st->pressure is also false, so we do not actually use press value, but it is impossible for the compiler to realize this, and it emits "uninitialized variable" warning. Fix this by initializing press to 0 and allows us to also remove an else clause that sets press to 0. Addresses-Coverity: ("Uninitialized scalar variable") Fixes: 60b7db914ddd ("Input: resistive-adc-touch - rework mapping of channels") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20210603220809.155118-1-colin.king@canonical.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/touchscreen/resistive-adc-touch.c')
-rw-r--r--drivers/input/touchscreen/resistive-adc-touch.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/input/touchscreen/resistive-adc-touch.c b/drivers/input/touchscreen/resistive-adc-touch.c
index ea7dd9d2b2ac..744544a723b7 100644
--- a/drivers/input/touchscreen/resistive-adc-touch.c
+++ b/drivers/input/touchscreen/resistive-adc-touch.c
@@ -59,7 +59,7 @@ static int grts_cb(const void *data, void *private)
{
const u16 *touch_info = data;
struct grts_state *st = private;
- unsigned int x, y, press;
+ unsigned int x, y, press = 0;
x = touch_info[st->ch_map[GRTS_CH_X]];
y = touch_info[st->ch_map[GRTS_CH_Y]];
@@ -84,8 +84,6 @@ static int grts_cb(const void *data, void *private)
*/
if (Rt < GRTS_DEFAULT_PRESSURE_MAX)
press = GRTS_DEFAULT_PRESSURE_MAX - Rt;
- else
- press = 0;
}
if ((!x && !y) || (st->pressure && (press < st->pressure_min))) {