From: sashiko-bot@kernel.org
To: "Sasha Finkelstein" <k@chaosmail.tech>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 3/3] usb: typec: tipd: Add sn201202x support
Date: Thu, 06 Aug 2026 09:56:03 +0000 [thread overview]
Message-ID: <20260806095604.54F2B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806-tipd-ace3-v4-3-79855b150914@chaosmail.tech>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] The suspend and resume handlers send SPMI sleep and wakeup commands directly to the hardware without acquiring `tps->lock` or the regmap lock, racing with concurrent I/O.
- [Low] The driver calls `devm_request_irq()` with a `NULL` `devname` parameter for the select, sleep, and wake interrupts, breaking interrupt debugging.
- [Low] Missing `depends on POWER_SUPPLY` for `CONFIG_TYPEC_SN201202X` causes a build failure.
Pre-existing issues:
- [High] Delayed works (`cd321x->update_work` and `tps->wq_poll`) are not cancelled on the `tipd_init()` error paths, leading to a Use-After-Free.
--
--- Patch [3]: [PATCH v4 3/3] usb: typec: tipd: Add sn201202x support ---
commit bad42a3c130cfb056927239566528c115c728126
Author: Sasha Finkelstein <k@chaosmail.tech>
usb: typec: tipd: Add sn201202x support
This commit adds support for the sn201202x (ACE3) controller. It is a tipd
variant that exposes a logical register interface over the SPMI bus.
> diff --git a/drivers/usb/typec/tipd/Kconfig b/drivers/usb/typec/tipd/Kconfig
> --- a/drivers/usb/typec/tipd/Kconfig
> +++ b/drivers/usb/typec/tipd/Kconfig
> @@ -14,3 +14,15 @@ config TYPEC_TPS6598X
>
> If you choose to build this driver as a dynamically linked module, the
> module will be called tps6598x.ko.
> +
> +config TYPEC_SN201202X
> + tristate "TI SN201202x USB Power Delivery controller support"
> + depends on SPMI
> + select TYPEC_TPS6598X_CORE
[Severity: Low]
Can this lead to a build failure when TYPEC_SN201202X is built into the kernel
and POWER_SUPPLY is built as a module?
TYPEC_TPS6598X_CORE uses power supply APIs, so if this symbol selects
TYPEC_TPS6598X_CORE without also depending on POWER_SUPPLY, it could cause
unresolved symbols during linking.
[ ... ]
> diff --git a/drivers/usb/typec/tipd/spmi.c b/drivers/usb/typec/tipd/spmi.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/usb/typec/tipd/spmi.c
[ ... ]
> +static int sn201202x_probe(struct spmi_device *device)
> +{
[ ... ]
> + init_completion(&sn->select_completion);
> + init_completion(&sn->sleep_completion);
> + init_completion(&sn->wake_completion);
> +
> + ret = devm_request_irq(&device->dev, irq_select, sn201202x_irq,
> + 0, NULL, &sn->select_completion);
[Severity: Low]
Is it intentional to pass NULL as the devname parameter for the select, sleep,
and wake interrupts here? Passing NULL causes these interrupts to be displayed
as (null) in /proc/interrupts and tracepoints, which might break interrupt
debugging tools.
[ ... ]
> + ret = spmi_command_wakeup(device);
> + if (ret)
> + return ret;
> + if (!wait_for_completion_timeout(&sn->wake_completion, msecs_to_jiffies(100)))
> + return -ETIMEDOUT;
> +
> + ret = tipd_init(tps);
> + if (ret)
> + spmi_command_sleep(device);
> + return ret;
> +}
[Severity: High]
This is a pre-existing issue, but does tipd_init() fail to cancel the delayed
works on its error paths?
If the driver is in polling mode, tipd_init() queues tps->wq_poll:
if (tps->irq) {
...
} else {
...
INIT_DELAYED_WORK(&tps->wq_poll, tps6598x_poll_work);
queue_delayed_work(system_power_efficient_wq, &tps->wq_poll,
msecs_to_jiffies(POLL_INTERVAL));
}
if (ret)
goto err_disconnect;
If connect() failed earlier and ret is set, or if another error occurs, it
jumps to err_disconnect and returns an error without cancelling the queued
delayed works. When probe fails, devres will free the tps structure,
potentially leaving a use-after-free when the work executes.
[ ... ]
> +static int __maybe_unused sn201202x_resume(struct device *dev)
> +{
> + struct tps6598x *tps = dev_get_drvdata(dev);
> + struct sn201202x *sn = tps_to_sn(tps);
> + int err;
> +
> + reinit_completion(&sn->wake_completion);
> + err = spmi_command_wakeup(sn->sdev);
[Severity: High]
Do the suspend and resume handlers race with concurrent regmap I/O?
Since the system workqueue is not freezable, cd321x->update_work can run
concurrently with sn201202x_suspend() and sn201202x_resume(). Sending SPMI
sleep or wakeup commands directly to the hardware without acquiring tps->lock
or the regmap lock could allow these commands to interleave with active
multi-register regmap transactions, potentially corrupting the bus state.
[ ... ]
> +static int __maybe_unused sn201202x_suspend(struct device *dev)
> +{
> + struct tps6598x *tps = dev_get_drvdata(dev);
> + struct sn201202x *sn = tps_to_sn(tps);
> + int err;
> +
> + err = tipd_suspend(tps);
> + if (err)
> + return err;
> + reinit_completion(&sn->sleep_completion);
> + err = spmi_command_sleep(sn->sdev);
[Severity: High]
Could the SPMI sleep command here also interleave with an active regmap
transaction if the update work executes concurrently?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260806-tipd-ace3-v4-0-79855b150914@chaosmail.tech?part=3
prev parent reply other threads:[~2026-08-06 9:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 9:37 [PATCH v4 0/3] usb: typec: tipd: Add sn201202x (ACE3) support Sasha Finkelstein
2026-08-06 9:37 ` [PATCH v4 1/3] dt-bindings: usb: tps6598x: Add sn201202x/ACE3 Sasha Finkelstein
2026-08-06 9:37 ` [PATCH v4 2/3] usb: typec: tipd: Factor out i2c specifics Sasha Finkelstein
2026-08-06 9:59 ` sashiko-bot
2026-08-06 9:37 ` [PATCH v4 3/3] usb: typec: tipd: Add sn201202x support Sasha Finkelstein
2026-08-06 9:56 ` 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=20260806095604.54F2B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=k@chaosmail.tech \
--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