From: Hongyan Xu <getshell@seu.edu.cn>
To: vkoul@kernel.org, kishon@kernel.org
Cc: Hongyan Xu <getshell@seu.edu.cn>,
linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org,
jianhao.xu@seu.edu.cn
Subject: [PATCH] phy: broadcom: ns2-usbdrd: cancel delayed work
Date: Tue, 28 Jul 2026 20:33:36 +0800 [thread overview]
Message-ID: <20260728123423.781-2-getshell@seu.edu.cn> (raw)
ns2_drd_phy_probe() initializes wq_extcon. Both GPIO IRQs and the probe
tail can queue it. There is no remove hook, so the delayed work can run
after driver-managed resources are being released.
Add a managed cleanup action before requesting IRQs. Devres releases the
IRQs first, then cancels the delayed work while extcon, GPIO and MMIO
state is still valid.
This issue was found by a static analysis tool.
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c b/drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c
index 36ad02c33..54929edb1 100644
--- a/drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c
+++ b/drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c
@@ -264,6 +264,13 @@ static irqreturn_t gpio_irq_handler(int irq, void *dev_id)
return IRQ_HANDLED;
}
+static void ns2_drd_phy_cancel_work(void *data)
+{
+ struct ns2_phy_driver *driver = data;
+
+ cancel_delayed_work_sync(&driver->wq_extcon);
+}
+
static const struct phy_ops ops = {
.init = ns2_drd_phy_init,
.power_on = ns2_drd_phy_poweron,
@@ -342,6 +349,10 @@ static int ns2_drd_phy_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&driver->wq_extcon, extcon_work);
+ ret = devm_add_action_or_reset(dev, ns2_drd_phy_cancel_work, driver);
+ if (ret)
+ return ret;
+
driver->id_irq = gpiod_to_irq(driver->id_gpiod);
if (driver->id_irq < 0) {
dev_err(dev, "failed to get ID IRQ\n");
--
2.50.1.windows.1
WARNING: multiple messages have this Message-ID (diff)
From: Hongyan Xu <getshell@seu.edu.cn>
To: vkoul@kernel.org, kishon@kernel.org
Cc: Hongyan Xu <getshell@seu.edu.cn>,
linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org,
jianhao.xu@seu.edu.cn
Subject: [PATCH] phy: broadcom: ns2-usbdrd: cancel delayed work
Date: Tue, 28 Jul 2026 20:33:36 +0800 [thread overview]
Message-ID: <20260728123423.781-2-getshell@seu.edu.cn> (raw)
ns2_drd_phy_probe() initializes wq_extcon. Both GPIO IRQs and the probe
tail can queue it. There is no remove hook, so the delayed work can run
after driver-managed resources are being released.
Add a managed cleanup action before requesting IRQs. Devres releases the
IRQs first, then cancels the delayed work while extcon, GPIO and MMIO
state is still valid.
This issue was found by a static analysis tool.
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c b/drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c
index 36ad02c33..54929edb1 100644
--- a/drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c
+++ b/drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c
@@ -264,6 +264,13 @@ static irqreturn_t gpio_irq_handler(int irq, void *dev_id)
return IRQ_HANDLED;
}
+static void ns2_drd_phy_cancel_work(void *data)
+{
+ struct ns2_phy_driver *driver = data;
+
+ cancel_delayed_work_sync(&driver->wq_extcon);
+}
+
static const struct phy_ops ops = {
.init = ns2_drd_phy_init,
.power_on = ns2_drd_phy_poweron,
@@ -342,6 +349,10 @@ static int ns2_drd_phy_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&driver->wq_extcon, extcon_work);
+ ret = devm_add_action_or_reset(dev, ns2_drd_phy_cancel_work, driver);
+ if (ret)
+ return ret;
+
driver->id_irq = gpiod_to_irq(driver->id_gpiod);
if (driver->id_irq < 0) {
dev_err(dev, "failed to get ID IRQ\n");
--
2.50.1.windows.1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next reply other threads:[~2026-07-28 12:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 12:33 Hongyan Xu [this message]
2026-07-28 12:33 ` [PATCH] phy: broadcom: ns2-usbdrd: cancel delayed work Hongyan Xu
2026-07-28 12:43 ` 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=20260728123423.781-2-getshell@seu.edu.cn \
--to=getshell@seu.edu.cn \
--cc=jianhao.xu@seu.edu.cn \
--cc=kishon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=vkoul@kernel.org \
/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.