From: sashiko-bot@kernel.org
To: "Fabrice Gasnier" <fabrice.gasnier@foss.st.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 2/2] usb: typec: mux: gpio-sbu: enable when only used for orientation
Date: Wed, 26 Aug 2026 12:30:14 +0000 [thread overview]
Message-ID: <20260826123014.CA6321F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260826-usb-fusb340-v1-v3-2-11927682504d@foss.st.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-after-free on driver unbind due to devres-managed objects accessed by registered callbacks.
--
commit ac2f1c36c2a2fd8f5788aba123b30da04e627199
Author: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
usb: typec: mux: gpio-sbu: enable when only used for orientation
When used as orientation-switch only (no mode-switch, e.g. no altmode),
the optional enable gpio remains disabled.
Enable it from the switch_set() routine, in this case, when the
orientation is set and the enable-gpios property has been provided.
> diff --git a/drivers/usb/typec/mux/gpio-sbu-mux.c b/drivers/usb/typec/mux/gpio-sbu-mux.c
> index 1834f1a2dd9dd..b1aa976aca240 100644
> --- a/drivers/usb/typec/mux/gpio-sbu-mux.c
> +++ b/drivers/usb/typec/mux/gpio-sbu-mux.c
[ ... ]
> @@ -120,6 +126,7 @@ static int gpio_sbu_mux_probe(struct platform_device *pdev)
> sw_desc.fwnode = dev_fwnode(dev);
> sw_desc.set = gpio_sbu_switch_set;
>
> + sbu_mux->mode_switch = device_property_read_bool(dev, "mode-switch");
> sbu_mux->sw = typec_switch_register(dev, &sw_desc);
> if (IS_ERR(sbu_mux->sw))
> return dev_err_probe(dev, PTR_ERR(sbu_mux->sw),
[Severity: High]
This is a pre-existing issue, but can this lead to a use-after-free during
driver unbind?
The sbu_mux struct is allocated with devres (devm_kzalloc), tying its
lifetime to the platform driver's bind state. However, the driver registers
callbacks with the Type-C subsystem via typec_switch_register().
When the driver unbinds (e.g., via sysfs), typec_switch_unregister() removes
the switch from sysfs but does not wait for active consumers who hold a
reference to the typec_switch_dev to drop their references.
After the driver's remove hook completes, the driver core's devres cleanup
runs and frees sbu_mux and the GPIO descriptors.
If a consumer holding a reference subsequently invokes typec_switch_set(),
it calls into gpio_sbu_switch_set() which blindly dereferences the freed
sbu_mux pointer (e.g., locking its mutex) and accesses freed GPIO structures.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260826-usb-fusb340-v1-v3-0-11927682504d@foss.st.com?part=2
next prev parent reply other threads:[~2026-08-26 12:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 12:16 [PATCH v3 0/2] usb: gpio-sbu-mux: add FUSB340 and enable option for orientation Fabrice Gasnier
2026-08-26 12:16 ` [PATCH v3 1/2] dt-bindings: usb: gpio-sbu-mux: Add compatible for FUSB340 Fabrice Gasnier
2026-09-01 6:31 ` Xu Yang
2026-09-01 8:02 ` Fabrice Gasnier
2026-09-01 10:08 ` Xu Yang
2026-08-26 12:16 ` [PATCH v3 2/2] usb: typec: mux: gpio-sbu: enable when only used for orientation Fabrice Gasnier
2026-08-26 12:30 ` sashiko-bot [this message]
2026-08-31 10:11 ` Heikki Krogerus
2026-09-01 14:02 ` [PATCH v3 0/2] usb: gpio-sbu-mux: add FUSB340 and enable option " Greg Kroah-Hartman
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=20260826123014.CA6321F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fabrice.gasnier@foss.st.com \
--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.