Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: linux-input@vger.kernel.org, lee@kernel.org, conor+dt@kernel.org,
	devicetree@vger.kernel.org, linux-leds@vger.kernel.org,
	dmitry.torokhov@gmail.com, robh@kernel.org
Subject: Re: [PATCH v10 3/7] input: serio: Add driver for ASUS Transformer dock keyboard and touchpad
Date: Tue, 21 Jul 2026 10:07:18 +0000	[thread overview]
Message-ID: <20260721100718.DE1E11F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260721095233.420823-4-clamor95@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Incorrect registration order of the notifier and serio ports leads to NULL pointer dereferences during probe and use-after-free bugs during driver removal.
--

--- Patch [3]: [PATCH v10 3/7] input: serio: Add driver for ASUS Transformer dock keyboard and touchpad ---
commit 4e9b70c95d0f43e6f5bf78aeff2f78f72b9b2f82
Author: Michał Mirosław <mirq-linux@rere.qmqm.pl>

input: serio: Add driver for ASUS Transformer dock keyboard and touchpad
    
Add input driver for ASUS Transformer dock keyboard and touchpad.

> diff --git a/drivers/input/serio/asus-transformer-ec-kbc.c b/drivers/input/serio/asus-transformer-ec-kbc.c
> new file mode 100644
> index 0000000000000..c6d12c44449d0
> --- /dev/null
> +++ b/drivers/input/serio/asus-transformer-ec-kbc.c

[ ... ]

> +static int asus_ec_kbc_notify(struct notifier_block *nb,
> +			      unsigned long action, void *data_)
> +{

[ ... ]

> +	while (n--)
> +		serio_interrupt(priv->sdev[port_idx], *data++, 0);
> +
> +	return NOTIFY_OK;
> +}

[ ... ]

> +static int asus_ec_kbc_probe(struct platform_device *pdev)
> +{
> +	struct asusec_core *ec = dev_get_drvdata(pdev->dev.parent);
> +	struct asus_ec_kbc_data *priv;
> +	int error;
> +
> +	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> +	if (!priv)
> +		return -ENOMEM;
> +
> +	platform_set_drvdata(pdev, priv);
> +
> +	priv->ec = ec;
> +	priv->parent = to_i2c_client(pdev->dev.parent);
> +
> +	priv->nb.notifier_call = asus_ec_kbc_notify;
> +
> +	error = blocking_notifier_chain_register(&ec->notify_list, &priv->nb);
> +	if (error)
> +		return dev_err_probe(&pdev->dev, error,
> +				     "failed to register blocking notifier chain");
> +
> +	error = devm_add_action_or_reset(&pdev->dev,
> +					 asus_ec_notifier_chain_unregister,
> +					 priv);
> +	if (error)
> +		return error;
> +
> +	error = asus_ec_register_serio(pdev, 0, "Keyboard", 0);
> +	if (error)
> +		return error;
> +
> +	error = asus_ec_register_serio(pdev, 1, "Touchpad", I8042_CMD_AUX_SEND);

[Severity: High]
Does this registration order leave the driver vulnerable to race conditions?

Since the parent MFD device might have already enabled its IRQ, an interrupt
can fire immediately after blocking_notifier_chain_register() completes. If
this occurs before the serio ports are registered, asus_ec_kbc_notify() will
read priv->sdev[port_idx] which is still NULL, and pass it to
serio_interrupt(), leading to a NULL pointer dereference.

Additionally, because devm actions execute in LIFO order during driver
removal or probe failure, the serio ports will be unregistered and freed
before the notifier is unregistered. If an interrupt fires during this
teardown window, could it pass a freed serio pointer to serio_interrupt()
and cause a use-after-free?

Should the notifier be registered only after the serio ports are fully
allocated and registered to prevent these crashes?

> +	if (error)
> +		return error;
> +
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260721095233.420823-1-clamor95@gmail.com?part=3

  reply	other threads:[~2026-07-21 10:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21  9:52 [PATCH v10 0/7] mfd: Add support for Asus Transformer embedded controller Svyatoslav Ryhel
2026-07-21  9:52 ` [PATCH v10 1/7] dt-bindings: embedded-controller: document ASUS Transformer EC Svyatoslav Ryhel
2026-07-21  9:59   ` sashiko-bot
2026-07-21  9:52 ` [PATCH v10 2/7] mfd: Add driver for ASUS Transformer embedded controller Svyatoslav Ryhel
2026-07-21 10:01   ` sashiko-bot
2026-07-21  9:52 ` [PATCH v10 3/7] input: serio: Add driver for ASUS Transformer dock keyboard and touchpad Svyatoslav Ryhel
2026-07-21 10:07   ` sashiko-bot [this message]
2026-07-21  9:52 ` [PATCH v10 4/7] input: keyboard: Add driver for ASUS Transformer dock multimedia keys Svyatoslav Ryhel
2026-07-21 10:00   ` sashiko-bot
2026-07-21  9:52 ` [PATCH v10 5/7] leds: Add driver for ASUS Transformer LEDs Svyatoslav Ryhel
2026-07-21 10:02   ` sashiko-bot
2026-07-21  9:52 ` [PATCH v10 6/7] power: supply: Add driver for ASUS Transformer battery Svyatoslav Ryhel
2026-07-21 10:04   ` sashiko-bot
2026-07-21  9:52 ` [PATCH v10 7/7] power: supply: Add charger driver for Asus Transformers Svyatoslav Ryhel
2026-07-21  9:59   ` 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=20260721100718.DE1E11F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=clamor95@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-leds@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