From: sashiko-bot@kernel.org
To: "Neil Armstrong" <neil.armstrong@linaro.org>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v2 2/4] usb: typec: qcom-pmic-typec: detach the port on shutdown
Date: Wed, 25 Nov 2026 11:18:42 +0000 [thread overview]
Message-ID: <sashiko-outbox-233215@kernel.org> (raw)
In-Reply-To: <20261125-topic-tcpm-qcom-fixes-v2-2-6fede9a69f6f@linaro.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] usb: typec: qcom: NULL deref in tcpm_vbus_change() on shutdown
with VBUS on
- [Medium] usb: typec: qcom: missing port_disable() on
qcom_pmic_typec_probe() error path
--
commit 274682eb5898a80edc0745dc8284b7d6afe1aba6
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 PD PHY
and Type-C port, unregisters the TCPM port, and disables the Type-C block,
and also calls port_disable() on driver removal.
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> index 58d1e6aae637d..be7508936796e 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec.c
> @@ -132,6 +132,17 @@ static void qcom_pmic_typec_remove(struct platform_device *pdev)
> tcpm->port_stop(tcpm);
> tcpm_unregister_port(tcpm->tcpm_port);
> fwnode_handle_put(tcpm->tcpc.fwnode);
> + tcpm->port_disable(tcpm);
> +}
[Severity: Medium]
Should the error unwind path in qcom_pmic_typec_probe() also call
tcpm->port_disable(tcpm)?
tcpm_register_port() (via qcom_pmic_typec_port_start_toggling()) and
tcpm->port_start() write an active role mode to TYPEC_MODE_CFG_REG. If a
later step in qcom_pmic_typec_probe() such as tcpm->pdphy_start() or
devm_drm_dp_hpd_bridge_add() fails, the error path unregisters the port
without disabling it, leaving Rp or Rd presented on CC with no driver bound.
> +
> +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);
> + tcpm->port_disable(tcpm);
> }
[Severity: High]
Can calling tcpm_unregister_port() here cause a NULL pointer dereference in
tcpm_vbus_change() when shutting down with an attached sink partner?
tcpm_unregister_port() destroys port->wq and sets port->wq = NULL before
calling tcpm_reset_port() -> tcpm_init_vbus() ->
qcom_pmic_typec_port_set_vbus(..., false, false). When VBUS was enabled,
qcom_pmic_typec_port_set_vbus() turns the regulator off and notifies TCPM:
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);
...
}
tcpm_vbus_change() then calls kthread_queue_work(port->wq, &port->event_work)
with port->wq == NULL, crashing in raw_spin_lock_irqsave(&worker->lock)
before tcpm->port_disable(tcpm) is reached.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-topic-tcpm-qcom-fixes-v2-0-6fede9a69f6f@linaro.org?part=2
next prev parent reply other threads:[~2026-11-25 11:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:04 [PATCH v2 0/4] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 1/4] usb: typec: qcom-pmic-typec: pdphy: disable the PD PHY on stop Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 2/4] usb: typec: qcom-pmic-typec: detach the port on shutdown Neil Armstrong
2026-11-25 11:18 ` sashiko-bot [this message]
2026-11-25 11:04 ` [PATCH v2 3/4] usb: typec: qcom-pmic-typec: switch to SNK_ONLY before DISABLE when disabling port Neil Armstrong
2026-11-25 11:04 ` [PATCH v2 4/4] usb: typec: qcom-pmic-typec: detach the port on probe Neil Armstrong
2026-11-25 11:13 ` sashiko-bot
2026-11-25 11:18 ` [PATCH v2 0/4] usb: typec: qcom-pmic-typec: properly tear down port on remove and shutdown sashiko-bot
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-233215@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