From: sashiko-bot@kernel.org
To: kr494167@gmail.com
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH] Input: charlieplex_keypad - check gpiod_direction_output() return value
Date: Thu, 23 Jul 2026 02:38:46 +0000 [thread overview]
Message-ID: <20260723023846.8909B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723022943.9337-1-kr494167@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The return value of `gpiod_direction_input()` is ignored, which can leave the line configured as an output driving HIGH upon hardware failure, breaking the matrix scanning logic.
--
--- Patch [1]: [PATCH] Input: charlieplex_keypad - check gpiod_direction_output() return value ---
commit dcc381a1c321f8eedf04b92519f6edd1db4050eb
Author: Surendra Singh Chouhan <kr494167@gmail.com>
Input: charlieplex_keypad - check gpiod_direction_output() return value
This commit updates charlieplex_keypad_scan_line() to capture and return
the error code if setting the active output line fails. This prevents
the keypad from continuing to sleep and read inputs from an improperly
configured GPIO.
> diff --git a/drivers/input/keyboard/charlieplex_keypad.c b/drivers/input/keyboard/charlieplex_keypad.c
> --- a/drivers/input/keyboard/charlieplex_keypad.c
> +++ b/drivers/input/keyboard/charlieplex_keypad.c
> @@ -77,7 +77,9 @@ static int charlieplex_keypad_scan_line(struct charlieplex_keypad *keypad,
> int err;
>
> /* Activate only one line as output at a time. */
> - gpiod_direction_output(line_gpios->desc[oline], 1);
> + err = gpiod_direction_output(line_gpios->desc[oline], 1);
> + if (err)
> + return err;
[Severity: High]
This is a pre-existing issue, but since this patch explicitly adds error
checking for gpiod_direction_output(), should we also check the return value
when restoring the line to an input state?
A few lines below in charlieplex_keypad_scan_line(), the same pattern exists
when restoring the line direction:
err = gpiod_get_array_value_cansleep(line_gpios->ndescs, ...);
gpiod_direction_input(line_gpios->desc[oline]);
if (err)
return err;
If gpiod_direction_input() fails here due to a temporary hardware or bus error
(like on an i2c or spi GPIO expander), does this leave the line configured
as an output driving high?
On subsequent scans, this could cause multiple lines to act as outputs
simultaneously and break the matrix scanning logic entirely.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260723022943.9337-1-kr494167@gmail.com?part=1
prev parent reply other threads:[~2026-07-23 2:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 2:29 [PATCH] Input: charlieplex_keypad - check gpiod_direction_output() return value kr494167
2026-07-23 2:38 ` sashiko-bot [this message]
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=20260723023846.8909B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=kr494167@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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