From: sashiko-bot@kernel.org
To: "Sasha Finkelstein" <k@chaosmail.tech>
Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH RESEND v7 3/3] usb: typec: tipd: Add sn201202x support
Date: Sat, 10 Oct 2026 09:59:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-166407@kernel.org> (raw)
In-Reply-To: <20261010-tipd-ace3-v7-3-317218a96c01@chaosmail.tech>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] usb: typec: tipd: Use-after-free of update_work on probe error path
- [Medium] usb: typec: tipd: sn201202x misses no_mode_control flag
--
commit 40f5bd6453edf7ec57cd88e8cdccab03d3c071c0
Author: Sasha Finkelstein <k@chaosmail.tech>
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
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -1962,11 +1962,32 @@ static const struct tipd_data tipd_tps25750_data = {
[ ... ]
> +static const struct tipd_data tipd_sn201202x_data = {
> + .irq_handler = cd321x_interrupt,
[Severity: Medium]
Should .no_mode_control = true be set here?
The sn201202x Type-C controller autonomously manages alternate mode
negotiation in hardware. By omitting .no_mode_control = true, the Type-C
core assumes the OS can control alternate modes, incorrectly exposing the
active and priority sysfs attributes as writable.
If a userspace daemon attempts to activate a mode via sysfs, the kernel
state will update without any hardware action, leading to a disjoint state
between kernel and hardware.
> + .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,
[Severity: High]
Can this cause a use-after-free on the probe error path?
If devm_request_threaded_irq() or any subsequent step fails in tipd_init()
after .connect has been called (e.g., when a partner is already plugged in
at boot), the error path jumps to err_unregister_port.
This path calls tps->data->unregister_port() (which maps to
cd321x_unregister_port here) but fails to invoke .remove or explicitly
cancel the pending cd321x->update_work delayed work.
The probe function returns an error, causing the devres framework to free
the struct sn201202x containing the work item. When the scheduled work
eventually executes on the system workqueue, it dereferences the freed
memory.
Is there a way to ensure cancel_delayed_work_sync(&cd321x->update_work) is
called during this error unwind?
> + .trace_data_status = trace_cd321x_data_status,
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261010-tipd-ace3-v7-0-317218a96c01@chaosmail.tech?part=3
prev parent reply other threads:[~2026-10-10 9:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 9:37 [PATCH RESEND v7 0/3] usb: typec: tipd: Add sn201202x (ACE3) support Sasha Finkelstein
2026-10-10 9:37 ` [PATCH RESEND v7 1/3] dt-bindings: usb: tps6598x: Add sn201202x/ACE3 Sasha Finkelstein
2026-10-10 9:47 ` sashiko-bot
2026-10-10 9:37 ` [PATCH RESEND v7 2/3] usb: typec: tipd: Factor out i2c specifics Sasha Finkelstein
2026-10-10 9:54 ` sashiko-bot
2026-10-10 9:37 ` [PATCH RESEND v7 3/3] usb: typec: tipd: Add sn201202x support Sasha Finkelstein
2026-10-10 9:59 ` 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=sashiko-outbox-166407@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=k@chaosmail.tech \
--cc=linux-usb@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