From: sashiko-bot@kernel.org
To: "Sasha Finkelstein" <k@chaosmail.tech>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 3/3] usb: typec: tipd: Add sn201202x support
Date: Mon, 27 Jul 2026 16:22:26 +0000 [thread overview]
Message-ID: <20260727162226.AC7991F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727-tipd-ace3-v2-3-1345957bd635@chaosmail.tech>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] `sn201202x_suspend` fails to rollback state if the SPMI sleep command fails, permanently breaking the device.
- [Medium] Missing SPMI sleep command on probe error path leaks hardware power state.
Pre-existing issues:
- [High] Pending delayed work is not canceled when `tipd_init()` fails, leading to Use-After-Free.
--
--- Patch [3]: [PATCH v2 3/3] usb: typec: tipd: Add sn201202x support ---
commit 698268fd8b63e1a6de3f13213aca2f84b22da5ef
Author: Sasha Finkelstein <k@chaosmail.tech>
Subject: usb: typec: tipd: Add sn201202x support
Add support for sn201202x (aka ACE3), a tipd variant that uses a very
similar register map, that is exposed over a "logical register"
interface on the SPMI bus.
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index aadadfdc6ed12..6577bc2f1e0f9 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
[ ... ]
> @@ -1889,6 +1889,26 @@ const struct tipd_data tipd_tps25750_data = {
> };
> EXPORT_SYMBOL_GPL(tipd_tps25750_data);
>
> +const struct tipd_data tipd_sn201202x_data = {
> + .irq_handler = cd321x_interrupt,
> + .irq_mask1 = APPLE_CD_REG_INT_POWER_STATUS_UPDATE |
> + APPLE_CD_REG_INT_DATA_STATUS_UPDATE |
> + APPLE_CD_REG_INT_PLUG_EVENT,
> + .tps_struct_size = sizeof(struct sn201202x),
> + .remove = cd321x_remove,
> + .register_port = cd321x_register_port,
> + .unregister_port = cd321x_unregister_port,
> + .trace_data_status = trace_cd321x_data_status,
> + .trace_power_status = trace_tps6598x_power_status,
> + .trace_status = trace_tps6598x_status,
> + .init = cd321x_init,
> + .read_data_status = cd321x_read_data_status,
> + .reset = cd321x_reset,
> + .switch_power_state = cd321x_switch_power_state,
> + .connect = cd321x_connect,
> +};
[Severity: High]
This is a pre-existing issue, but does this error path leave delayed work
pending, potentially causing a use-after-free?
In tipd_init(), if a plug is present, tps->data->connect(tps, status)
is called. For this struct, that resolves to cd321x_connect(), which
schedules delayed work.
If a subsequent step in tipd_init() fails (like requesting the IRQ):
core.c:tipd_init() {
...
if (tps->irq) {
ret = devm_request_threaded_irq(...);
}
if (ret)
goto err_disconnect;
...
The err_disconnect label does not cancel the delayed work before returning:
err_disconnect:
tps6598x_disconnect(tps, 0);
err_unregister_port:
tps->data->unregister_port(tps);
...
When devres frees the device structure memory on probe failure, won't the
workqueue execute the callback on the freed memory when the timer expires?
> 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)
> +{
[ ... ]
> + ret = spmi_command_wakeup(device);
> + if (ret)
> + return ret;
> + if (!wait_for_completion_timeout(&sn->wake_completion, msecs_to_jiffies(100)))
> + return -ETIMEDOUT;
> +
> + return tipd_init(tps);
> +}
[Severity: Medium]
Does this leak the hardware power state if tipd_init() fails?
If tipd_init(tps) fails, the error is returned directly. Should this path
call spmi_command_sleep() to reverse the spmi_command_wakeup() called
earlier in this function?
[ ... ]
> +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);
> + if (err)
> + return err;
> + if (!wait_for_completion_timeout(&sn->sleep_completion, msecs_to_jiffies(100)))
> + return -ETIMEDOUT;
> + return 0;
> +}
[Severity: High]
If spmi_command_sleep() fails or times out, does the device state need to be
rolled back?
If this returns an error, the PM core aborts system suspend but does not
invoke the resume callback for the failing device. Should this path call
tipd_resume(tps) to undo the effects of tipd_suspend(tps) before returning,
so the device is not left permanently broken and unresponsive?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727-tipd-ace3-v2-0-1345957bd635@chaosmail.tech?part=3
prev parent reply other threads:[~2026-07-27 16:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 16:09 [PATCH v2 0/3] usb: typec: tipd: Add sn201202x (ACE3) support Sasha Finkelstein
2026-07-27 16:09 ` [PATCH v2 1/3] dt-bindings: usb: tps6598x: Add sn201202x/ACE3 Sasha Finkelstein
2026-07-27 16:09 ` [PATCH v2 2/3] usb: typec: tipd: Factor out i2c specifics Sasha Finkelstein
2026-07-27 16:23 ` sashiko-bot
2026-07-27 16:09 ` [PATCH v2 3/3] usb: typec: tipd: Add sn201202x support Sasha Finkelstein
2026-07-27 16:22 ` 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=20260727162226.AC7991F000E9@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 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.