From: Colin King <colin.king@canonical.com>
To: Eugen Hristev <eugen.hristev@microchip.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-input@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] Input: resistive-adc-touch: Fix uninitialized variable 'press'
Date: Thu, 3 Jun 2021 23:08:09 +0100 [thread overview]
Message-ID: <20210603220809.155118-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
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. This affects a later
comparison of press < st->pressure_min. 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>
---
drivers/input/touchscreen/resistive-adc-touch.c | 4 +---
1 file changed, 1 insertion(+), 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))) {
--
2.31.1
next reply other threads:[~2021-06-03 22:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 22:08 Colin King [this message]
2021-06-05 23:19 ` [PATCH][next] Input: resistive-adc-touch: Fix uninitialized variable 'press' Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210603220809.155118-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=dmitry.torokhov@gmail.com \
--cc=eugen.hristev@microchip.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).