Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jun Yan" <jerrysteve1101@gmail.com>
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, dmitry.torokhov@gmail.com, conor+dt@kernel.org
Subject: Re: [PATCH v2 6/9] Input: cap11xx - add reset gpio support
Date: Fri, 12 Jun 2026 07:31:49 +0000	[thread overview]
Message-ID: <20260612073150.185DB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260612072237.1177304-7-jerrysteve1101@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Medium] Unintended glitch on the reset line during probe due to GPIOD_OUT_LOW initialization.

Pre-existing issues:
- [High] Unvalidated keycodes from Device Tree cause an out-of-bounds heap write.
--

commit 5befbfbb7019f474fe2d2d2e0e3da23976b75ada
Author: Jun Yan <jerrysteve1101@gmail.com>

Input: cap11xx - add reset gpio support

Some CAP11xx devices (CAP1126/CAP1188) have a dedicated RESET pin. Add
hardware reset operation to improve device reliability and ensure proper
initialization on probe.

> diff --git a/drivers/input/keyboard/cap11xx.c b/drivers/input/keyboard/cap11xx.c
> index 686174722204c..75746a8a22332 100644
> --- a/drivers/input/keyboard/cap11xx.c
> +++ b/drivers/input/keyboard/cap11xx.c

[ ... ]

> @@ -452,6 +457,17 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client)
>  	if (IS_ERR(priv->regmap))
>  		return PTR_ERR(priv->regmap);
>  
> +	priv->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
> +	if (IS_ERR(priv->reset_gpio))
> +		return dev_err_probe(dev, PTR_ERR(priv->reset_gpio),
> +				     "Failed to get 'reset' GPIO\n");
> +	if (priv->reset_gpio) {
> +		gpiod_set_value_cansleep(priv->reset_gpio, 1);

[Severity: Medium]
Does initializing the reset GPIO with GPIOD_OUT_LOW cause an unintended
glitch on the reset line?

When devm_gpiod_get_optional() is called with GPIOD_OUT_LOW, the GPIO line
is immediately driven to its logical low (inactive) state. If the hardware
or bootloader previously left the device in a reset state, this prematurely
pulls it out of reset.

The driver then immediately calls gpiod_set_value_cansleep() to assert
the reset. This sequence creates an extremely short, unintended
de-assert/assert glitch on the reset pin, which could violate hardware
timing requirements.

Would it be safer to request the reset GPIO with GPIOD_OUT_HIGH (or
GPIOD_ASIS) to guarantee it starts in the logically asserted state before
we hold it for the required minimum duration?

[Severity: High]
This is a pre-existing issue, but does this code overflow the keybit array
if a device tree provides unvalidated keycodes?

Later in cap11xx_i2c_probe(), the driver loops over the keycodes read from
the device tree:

for (i = 0; i < cap->num_channels; i++)
        __set_bit(priv->keycodes[i], priv->idev->keybit);

Since __set_bit() does not perform bounds checking, if a device tree
specifies a keycode value greater than or equal to KEY_MAX, this will
write outside the bounds of the keybit array in the input_dev structure,
clobbering adjacent memory in the kernel heap.

Should we add a check against KEY_MAX before setting the bit?

> +		usleep_range(CAP11XX_T_RST_FILT_MIN_US, CAP11XX_T_RST_FILT_MIN_US * 2);
> +		gpiod_set_value_cansleep(priv->reset_gpio, 0);
> +		msleep(CAP11XX_T_RST_ON_MIN_MS);
> +	}
> +
>  	error = regmap_read(priv->regmap, CAP11XX_REG_PRODUCT_ID, &val);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260612072237.1177304-1-jerrysteve1101@gmail.com?part=6

  reply	other threads:[~2026-06-12  7:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-12  7:22 [PATCH v2 0/9] Input: cap11xx - Add support for CAP1114 Jun Yan
2026-06-12  7:22 ` [PATCH v2 1/9] Input: cap11xx - clean up duplicate log and add probe error logs Jun Yan
2026-06-12  7:32   ` sashiko-bot
2026-06-12  7:22 ` [PATCH v2 2/9] Input: cap11xx - remove unused register macros Jun Yan
2026-06-12  7:22 ` [PATCH v2 3/9] dt-bindings: input: microchip,cap11xx: Update datasheet URL and LED reg range Jun Yan
2026-06-12  7:22 ` [PATCH v2 4/9] dt-bindings: input: microchip,cap11xx: Add microchip,cap1126 LED reg constraints Jun Yan
2026-06-12  7:22 ` [PATCH v2 5/9] dt-bindings: input: microchip,cap11xx: Add reset-gpios property Jun Yan
2026-06-12  7:32   ` sashiko-bot
2026-06-12  7:22 ` [PATCH v2 6/9] Input: cap11xx - add reset gpio support Jun Yan
2026-06-12  7:31   ` sashiko-bot [this message]
2026-06-12  7:22 ` [PATCH v2 7/9] Input: cap11xx - refactor code for better CAP1114 support Jun Yan
2026-06-12  7:35   ` sashiko-bot
2026-06-12  7:22 ` [PATCH v2 8/9] dt-bindings: input: microchip,cap11xx: Add " Jun Yan
2026-06-12  7:35   ` sashiko-bot
2026-06-12  7:22 ` [PATCH v2 9/9] Input: cap11xx - add support for CAP1114 Jun Yan
2026-06-12  7:42   ` sashiko-bot

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=20260612073150.185DB1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jerrysteve1101@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=robh@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