From: sashiko-bot@kernel.org
To: "Marek Vasut" <marek.vasut+renesas@mailbox.org>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/2] extcon: ptn5150: Make CON_DET configurable
Date: Sun, 29 Nov 2026 17:26:48 +0000 [thread overview]
Message-ID: <sashiko-outbox-239833@kernel.org> (raw)
In-Reply-To: <20261129171935.280160-2-marek.vasut+renesas@mailbox.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] extcon: ptn5150: unchecked regmap_clear_bits() return in
ptn5150_i2c_probe()
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Critical] extcon: ptn5150: orient_sw leak and irq_work race in
ptn5150_i2c_probe() [1]
--
commit aeab3d399b32bd1935fe640269c15aa72b9b637c
Author: Marek Vasut <marek.vasut+renesas@mailbox.org>
extcon: ptn5150: Make CON_DET configurable
This commit adds support for the "nxp,con-det-enable" boolean property to
enable the CON_DET output signal on the PTN5150 chip during probe.
> diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
> index eca1b140aeb0f..7d462680dd88e 100644
> --- a/drivers/extcon/extcon-ptn5150.c
> +++ b/drivers/extcon/extcon-ptn5150.c
[ ... ]
> @@ -362,6 +363,11 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c)
> if (ret)
> return ret;
[Severity: Critical]
This problem wasn't introduced by this patch, but registering
ptn5150_work_sync_and_put() via devm_add_action_or_reset() here is ordered
after devm_request_threaded_irq() and after acquiring info->orient_sw
[1]:
drivers/extcon/extcon-ptn5150.c:ptn5150_i2c_probe() {
...
ret = devm_request_threaded_irq(dev, info->irq, NULL,
ptn5150_irq_handler, ...);
...
if (connector) {
info->orient_sw = fwnode_typec_switch_get(connector);
if (IS_ERR(info->orient_sw))
return dev_err_probe(...);
}
info->role_sw = usb_role_switch_get(info->dev);
if (!info->role_sw && connector)
info->role_sw = fwnode_usb_role_switch_get(connector);
if (IS_ERR(info->role_sw))
return dev_err_probe(...);
ret = devm_add_action_or_reset(dev, ptn5150_work_sync_and_put, info);
...
}
Because devres runs teardown actions in reverse order, could an interrupt
fire after ptn5150_work_sync_and_put() runs and before the IRQ is freed?
CPU0 CPU1
ptn5150_work_sync_and_put()
cancel_work_sync(&info->irq_work)
usb_role_switch_put(info->role_sw)
typec_switch_put(info->orient_sw)
ptn5150_irq_handler()
schedule_work(&info->irq_work)
devm_irq_release()
devm kfree(info)
ptn5150_irq_work()
mutex_lock(&info->mutex)
<-- use-after-free
In addition, if acquiring info->role_sw fails, probe returns before
ptn5150_work_sync_and_put() is registered, leaking info->orient_sw and
leaving any already-scheduled info->irq_work uncanceled.
> +
> + if (device_property_present(&i2c->dev, "nxp,con-det-enable")) {
> + regmap_clear_bits(info->regmap, PTN5150_REG_CON_DET,
> + PTN5150_REG_CON_DET_DIS);
> + }
[Severity: Low]
Should the return value of regmap_clear_bits() be checked and propagated?
If the I2C transfer fails, probe will succeed with CON_DET still disabled.
[1] https://sashiko.dev/#/bug/linux-475a50da-a64e-4ed0-a654-d7f65166df20
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129171935.280160-1-marek.vasut+renesas@mailbox.org?part=2
prev parent reply other threads:[~2026-11-29 17:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 17:19 [PATCH 1/2] dt-bindings: extcon: ptn5150: Document CON_DET enable Marek Vasut
2026-11-29 17:19 ` [PATCH 2/2] extcon: ptn5150: Make CON_DET configurable Marek Vasut
2026-11-29 17:26 ` 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-239833@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=marek.vasut+renesas@mailbox.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