From: "Alvin Šipraga" <alvin.sipraga@analog.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH] Input: adp5588-keys - cache GPIO state before registering the gpiochip
Date: Tue, 18 Aug 2026 18:27:21 +0200 [thread overview]
Message-ID: <aoSFhKxPk-QPv2EQ@analog.com> (raw)
In-Reply-To: <20260818161119.E25A31F00A3A@smtp.kernel.org>
Thanks for your review sashiko-bot,
On Tue, Aug 18, 2026 at 04:11:19PM +0000, sashiko-bot@kernel.org wrote:
> [Severity: High]
> This isn't a bug introduced by this patch, but this patch actively
> exacerbates the consequences of a pre-existing issue with missing error
> handling on I2C reads.
>
> If adp5588_read() fails due to a bus fault, it returns a negative error
> code (e.g., -EIO). In adp5588_gpio_add(), these negative values are
> silently truncated to 8-bit unsigned values and stored in the driver's
> cached GPIO state (dat_out, dir, pull_dis).
>
> Because this patch moves this caching to occur before
> devm_gpiochip_add_data(), when a GPIO hog is subsequently applied, the
> driver inadvertently clobbers the real hardware state by writing back this
> error-corrupted cache. Can this actively undermine the patch's stated goal
> of preserving bootloader GPIO configurations if an I2C read fails during
> probe?
If the reads fail, I would not expect the driver to behave properly at
all - neither before nor after this patch. It's true that this patch
might trade some broken behavior for another type of broken behavior
though. But only on systems where I2C reads are failing.
If the argument is that such a trade can be considered a regression, I
would point out that the suggestion here - to add error checking and to
fail probe on bus errors - would invariably cause probe failure on such
systems with buggy I2C reads. That's also a regression.
> Additionally, this same missing error check causes severe issues elsewhere.
> In adp5588_report_events(), the error is bitwise-ANDed with KEY_EV_MASK,
> resulting in an invalid, large key value. This yields a calculated code
> index that exceeds the bounds of the kpad->keycode array, causing an
> out-of-bounds heap read and leaking phantom key presses to userspace.
>
> Finally, in adp5588_gpio_get_value(), a negative error code evaluates to
> true, incorrectly reporting the pin state as HIGH.
>
> Would it be appropriate to add proper error checking to adp5588_read() or
> its callers to prevent state corruption and out-of-bounds memory access
> during I2C faults?
Sure the driver can be improved by adding error checking, but that would
be a much larger change. I hope that is not an impediment to getting
this particular issue fixed.
Alvin
prev parent reply other threads:[~2026-08-18 16:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 16:00 [PATCH] Input: adp5588-keys - cache GPIO state before registering the gpiochip Alvin Šipraga
2026-08-18 16:08 ` Nuno Sá
2026-08-18 16:11 ` sashiko-bot
2026-08-18 16:27 ` Alvin Šipraga [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=aoSFhKxPk-QPv2EQ@analog.com \
--to=alvin.sipraga@analog.com \
--cc=dmitry.torokhov@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.