From: sashiko-bot@kernel.org
To: "Neil Armstrong" <neil.armstrong@linaro.org>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH 2/2] usb: typec: qcom-pmic-typec: detach the port on shutdown
Date: Fri, 20 Nov 2026 10:15:03 +0000 [thread overview]
Message-ID: <sashiko-outbox-224916@kernel.org> (raw)
In-Reply-To: <20261120-topic-tcpm-qcom-fixes-v1-2-9a152f906fba@linaro.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] usb: typec: qcom: NULL deref in qcom_pmic_typec_shutdown() when
VBUS is on
- [Medium] usb: typec: qcom-pmic-typec: missing port_disable() in remove
and probe unwind
--
commit 27e120f037d3faf6c51dac7774569601de458e75
Author: Neil Armstrong <neil.armstrong@linaro.org>
usb: typec: qcom-pmic-typec: detach the port on shutdown
This commit adds a platform driver shutdown callback that stops the port
and PD PHY, unregisters the TCPM port, and disables the Type-C block so
that a connected partner sees a detach on reboot or power off.
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> index 58d1e6aae637d..8169db478b8aa 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> @@ -134,6 +134,16 @@ static void qcom_pmic_typec_remove(struct platform_device *pdev)
> fwnode_handle_put(tcpm->tcpc.fwnode);
> }
>
> +static void qcom_pmic_typec_shutdown(struct platform_device *pdev)
> +{
> + struct pmic_typec *tcpm = platform_get_drvdata(pdev);
> +
> + tcpm->pdphy_stop(tcpm);
> + tcpm->port_stop(tcpm);
> + tcpm_unregister_port(tcpm->tcpm_port);
[Severity: High]
Can calling tcpm_unregister_port() here cause a NULL pointer dereference
on port->wq when shutting down with an attached sink partner powered by
VBUS?
tcpm_unregister_port() destroys port->wq and sets it to NULL before
calling tcpm_reset_port() -> tcpm_init_vbus() ->
qcom_pmic_typec_port_set_vbus(). When VBUS transitions from enabled to
disabled, qcom_pmic_typec_port_set_vbus() calls tcpm_vbus_change(), which
queues work onto port->wq:
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c:qcom_pmic_typec_port_set_vbus() {
...
ret = qcom_pmic_typec_port_vbus_toggle(pmic_typec_port, on);
if (ret)
goto done;
pmic_typec_port->vbus_enabled = on;
tcpm_vbus_change(tcpm->tcpm_port);
...
}
kthread_queue_work() then dereferences NULL in &worker->lock, crashing
before tcpm->port_disable(tcpm) is reached.
> + tcpm->port_disable(tcpm);
> +}
[Severity: Medium]
Should tcpm->port_disable(tcpm) also be called in qcom_pmic_typec_remove()
and the port_unregister error path in qcom_pmic_typec_probe()?
Without it, unbinding the driver or failing probe after
tcpm_register_port() leaves TYPEC_MODE_CFG_REG presenting Rp or Rd with no
TCPM or PD PHY servicing the port, and a subsequent reboot or power off
will not invoke qcom_pmic_typec_shutdown() on the unbound device.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-topic-tcpm-qcom-fixes-v1-0-9a152f906fba@linaro.org?part=2
next prev parent reply other threads:[~2026-11-20 10:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 9:59 [PATCH 0/2] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown Neil Armstrong
2026-11-20 9:59 ` [PATCH 1/2] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop Neil Armstrong
2026-11-20 10:03 ` sashiko-bot
2026-11-20 9:59 ` [PATCH 2/2] usb: typec: qcom-pmic-typec: detach the port on shutdown Neil Armstrong
2026-11-20 10:15 ` sashiko-bot [this message]
2026-11-20 10:53 ` Neil Armstrong
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-224916@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=neil.armstrong@linaro.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