From: sashiko-bot@kernel.org
To: taygoth <taygoth@gmail.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 3/6] usb: typec: add Qualcomm PMI8998 role-switch driver
Date: Mon, 18 May 2026 20:58:20 +0000 [thread overview]
Message-ID: <20260518205821.49435C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <6fedbcd344505b63de72037f69ea94f916255f03.1779127507.git.taygoth@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Race condition and Use-After-Free during driver removal due to mixed devm and manual cleanup.
- [Medium] VBUS regulator enable count leak on probe error path.
- [Medium] Silently ignored return value of hardware initialization in probe().
--
commit 2be57d2a22cd876c2f33d5adcda09af34cd9c497
Author: taygoth <taygoth@gmail.com>
usb: typec: add Qualcomm PMI8998 role-switch driver
This commit introduces a new USB Type-C role-switch driver for the Qualcomm
PMI8998 PMIC. It translates the hardware-detected role into a consumer
switch state, and enables an optional VBUS supply regulator when acting as
a USB host.
> diff --git a/drivers/usb/typec/qcom_pmi8998_typec.c b/drivers/usb/typec/qcom_pmi8998_typec.c
> new file mode 100644
> index 0000000000000..77662b4f1b0c6
> --- /dev/null
> +++ b/drivers/usb/typec/qcom_pmi8998_typec.c
[ ... ]
> +static int pmi8998_typec_probe(struct platform_device *pdev)
> +{
[ ... ]
> + platform_set_drvdata(pdev, typec);
> +
> + pmi8998_typec_apply(typec);
Should the return value of pmi8998_typec_apply() be checked here?
If operations like regmap_read() or regulator_enable() fail inside apply(),
the probe will silently succeed with an unsynchronized hardware state.
> +
> + ret = devm_request_threaded_irq(dev, typec->irq, NULL,
> + pmi8998_typec_isr, IRQF_ONESHOT,
> + dev_name(dev), typec);
> + if (ret)
> + goto err_role_put;
> +
> + return 0;
> +
> +err_role_put:
> + usb_role_switch_put(typec->role_sw);
If pmi8998_typec_apply() above evaluates to USB_ROLE_HOST, it will enable
the vbus regulator and set typec->vbus_enabled to true.
If the interrupt request then fails, does this error path leak the regulator
enable count by missing a regulator_disable() call?
> + return ret;
> +}
> +
> +static void pmi8998_typec_remove(struct platform_device *pdev)
> +{
> + struct pmi8998_typec *typec = platform_get_drvdata(pdev);
> +
> + if (typec->vbus_enabled)
> + regulator_disable(typec->vbus);
> + usb_role_switch_put(typec->role_sw);
Because the interrupt was requested using devm_request_threaded_irq(), it
will not be freed until after pmi8998_typec_remove() returns.
If a hardware interrupt fires right after we disable the regulator and
put the role switch:
pmi8998_typec_remove()
regulator_disable(typec->vbus);
usb_role_switch_put(typec->role_sw);
-> interrupt fires
pmi8998_typec_isr()
pmi8998_typec_apply()
Could the ISR attempt to use the freed typec->role_sw or perform an
unbalanced regulator_disable() since typec->vbus_enabled is never set
to false in remove()?
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1779127507.git.taygoth@gmail.com?part=3
next prev parent reply other threads:[~2026-05-18 20:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 20:22 [PATCH 0/6] usb: typec: add Qualcomm PMI8998 USB Type-C role-switch support taygoth
2026-05-18 20:22 ` [PATCH 1/6] dt-bindings: regulator: qcom,usb-vbus-regulator: add PMI8998 taygoth
2026-05-18 21:56 ` Bryan O'Donoghue
2026-05-19 10:51 ` Krzysztof Kozlowski
2026-05-18 20:22 ` [PATCH 2/6] dt-bindings: usb: add Qualcomm PMI8998 Type-C controller taygoth
2026-05-18 20:42 ` sashiko-bot
2026-05-18 22:03 ` Dmitry Baryshkov
2026-05-18 20:22 ` [PATCH 3/6] usb: typec: add Qualcomm PMI8998 role-switch driver taygoth
2026-05-18 20:58 ` sashiko-bot [this message]
2026-05-18 21:45 ` Dmitry Baryshkov
2026-05-18 22:07 ` Bryan O'Donoghue
2026-05-18 22:09 ` Bryan O'Donoghue
2026-05-19 10:52 ` Krzysztof Kozlowski
2026-05-18 20:22 ` [PATCH 4/6] arm64: dts: qcom: pmi8998: add USB Type-C and VBUS regulator nodes taygoth
2026-05-18 21:19 ` sashiko-bot
2026-05-18 20:22 ` [PATCH 5/6] arm64: dts: qcom: sdm845-oneplus-common: enable USB Type-C role switching taygoth
2026-05-18 21:36 ` sashiko-bot
2026-05-18 20:22 ` [PATCH 6/6] MAINTAINERS: add entry for Qualcomm PMI8998 USB Type-C driver taygoth
2026-05-18 21:59 ` [PATCH 0/6] usb: typec: add Qualcomm PMI8998 USB Type-C role-switch support Bryan O'Donoghue
[not found] ` <CAFPzRonyVt9Kd+Sc0ooNz8By6b-Zr_jHr0sBXv-M25dQ0w9Cjg@mail.gmail.com>
2026-05-18 23:43 ` Bryan O'Donoghue
2026-05-19 11:12 ` Konrad Dybcio
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=20260518205821.49435C2BCB7@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=taygoth@gmail.com \
/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