* [PATCH 0/6] usb: add missing pm_runtime_dont_use_autosuspend() calls
@ 2026-09-15 9:02 Joshua Crofts
2026-09-15 9:02 ` [PATCH 1/6] usb: core: add missing pm_runtime_dont_use_autosuspend() call Joshua Crofts
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: Joshua Crofts @ 2026-09-15 9:02 UTC (permalink / raw)
To: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Mathias Nyman, Chunfeng Yun, Matthias Brugger,
AngeloGioacchino Del Regno, Heikki Krogerus
Cc: linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
Several drivers in the USB subsystem forget to call dont_use_autosuspend()
on teardown or error, causing potential resource leaks. This series adds
the missing calls.
The offending drivers were found using a semantic patch for Coccinelle
I'm working on [1].
[1] https://lore.kernel.org/all/20260915064327.1377-1-joshua.crofts1@gmail.com/
Joshua Crofts (6):
usb: core: add missing pm_runtime_dont_use_autosuspend() call
usb: xhci-mtk: add missing pm_runtime_dont_use_autosuspend() call
usb: xhci: add missing pm_runtime_dont_use_autosuspend() calls
usb: typec: ucsi: ccg: add missing pm_runtime_dont_use_autosuspend()
call
usb: mtu3: add missing pm_runtime_dont_use_autosuspend() calls
usb: cdns3: add missing pm_runtime_dont_use_autosuspend() call
drivers/usb/cdns3/cdns3-plat.c | 1 +
drivers/usb/core/hub.c | 1 +
drivers/usb/host/xhci-mtk.c | 2 ++
drivers/usb/host/xhci-plat.c | 2 ++
drivers/usb/mtu3/mtu3_plat.c | 2 ++
drivers/usb/typec/ucsi/ucsi_ccg.c | 1 +
6 files changed, 9 insertions(+)
--
2.47.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/6] usb: core: add missing pm_runtime_dont_use_autosuspend() call
2026-09-15 9:02 [PATCH 0/6] usb: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
@ 2026-09-15 9:02 ` Joshua Crofts
2026-09-15 15:02 ` Alan Stern
2026-09-16 8:08 ` Johan Hovold
2026-09-15 9:02 ` [PATCH 2/6] usb: xhci-mtk: " Joshua Crofts
` (4 subsequent siblings)
5 siblings, 2 replies; 14+ messages in thread
From: Joshua Crofts @ 2026-09-15 9:02 UTC (permalink / raw)
To: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Mathias Nyman, Chunfeng Yun, Matthias Brugger,
AngeloGioacchino Del Regno, Heikki Krogerus
Cc: linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek, stable
The fail label in usb_new_device() disables pm_runtime on failure, but
doesn't call pm_runtime_dont_use_autosuspend(), causing resource leaks.
Add the missing pm_runtime_dont_use_autosuspend() call.
Found using Coccinelle.
Fixes: fcc4a01eb866 ("USB: use the runtime-PM autosuspend implementation")
Cc: <stable@vger.kernel.org>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
drivers/usb/core/hub.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 3345b3298daf..dec6d5c49759 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2745,6 +2745,7 @@ int usb_new_device(struct usb_device *udev)
fail:
usb_set_device_state(udev, USB_STATE_NOTATTACHED);
pm_runtime_disable(&udev->dev);
+ pm_runtime_dont_use_autosuspend(&udev->dev);
pm_runtime_set_suspended(&udev->dev);
return err;
}
--
2.47.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/6] usb: xhci-mtk: add missing pm_runtime_dont_use_autosuspend() call
2026-09-15 9:02 [PATCH 0/6] usb: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
2026-09-15 9:02 ` [PATCH 1/6] usb: core: add missing pm_runtime_dont_use_autosuspend() call Joshua Crofts
@ 2026-09-15 9:02 ` Joshua Crofts
2026-09-15 9:10 ` AngeloGioacchino Del Regno
2026-09-16 8:16 ` Johan Hovold
2026-09-15 9:02 ` [PATCH 3/6] usb: xhci: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
` (3 subsequent siblings)
5 siblings, 2 replies; 14+ messages in thread
From: Joshua Crofts @ 2026-09-15 9:02 UTC (permalink / raw)
To: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Mathias Nyman, Chunfeng Yun, Matthias Brugger,
AngeloGioacchino Del Regno, Heikki Krogerus
Cc: linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek, stable
The disable_pm label in xhci_mtk_probe() and xhci_mtk_remove() both call
pm_runtime_disable() on error or device teardown, but don't call
pm_runtime_dont_use_autosuspend(), causing resource leaks.
Add the missing pm_runtime_dont_use_autosuspend().
Found using Coccinelle.
Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host controller")
Fixes: 04284eb74e0c ("usb: xhci-mtk: add support runtime PM")
Cc: <stable@vger.kernel.org>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
drivers/usb/host/xhci-mtk.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 60af5fe29bd4..eb483a267bf6 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -700,6 +700,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
disable_pm:
pm_runtime_put_noidle(dev);
pm_runtime_disable(dev);
+ pm_runtime_dont_use_autosuspend(dev);
return ret;
}
@@ -731,6 +732,7 @@ static void xhci_mtk_remove(struct platform_device *pdev)
regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies);
pm_runtime_disable(dev);
+ pm_runtime_dont_use_autosuspend(dev);
pm_runtime_put_noidle(dev);
pm_runtime_set_suspended(dev);
}
--
2.47.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/6] usb: xhci: add missing pm_runtime_dont_use_autosuspend() calls
2026-09-15 9:02 [PATCH 0/6] usb: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
2026-09-15 9:02 ` [PATCH 1/6] usb: core: add missing pm_runtime_dont_use_autosuspend() call Joshua Crofts
2026-09-15 9:02 ` [PATCH 2/6] usb: xhci-mtk: " Joshua Crofts
@ 2026-09-15 9:02 ` Joshua Crofts
2026-09-15 9:02 ` [PATCH 4/6] usb: typec: ucsi: ccg: add missing pm_runtime_dont_use_autosuspend() call Joshua Crofts
` (2 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Joshua Crofts @ 2026-09-15 9:02 UTC (permalink / raw)
To: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Mathias Nyman, Chunfeng Yun, Matthias Brugger,
AngeloGioacchino Del Regno, Heikki Krogerus
Cc: linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek, stable
The disable_runtime label in xhci_plat_probe() and xhci_plat_remove() both
call pm_runtime_disable() on error or device teardown, but don't call
pm_runtime_dont_use_autosuspend(), causing resource leaks.
Add the missing pm_runtime_dont_use_autosuspend().
Found using Coccinelle.
Fixes: b0c69b4bace3 ("usb: host: plat: Enable xHCI plat runtime PM")
Cc: <stable@vger.kernel.org>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
drivers/usb/host/xhci-plat.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 6fd595f81a30..29e743d6868e 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -388,6 +388,7 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s
disable_runtime:
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
+ pm_runtime_dont_use_autosuspend(&pdev->dev);
return ret;
}
@@ -461,6 +462,7 @@ void xhci_plat_remove(struct platform_device *dev)
usb_put_hcd(hcd);
pm_runtime_disable(&dev->dev);
+ pm_runtime_dont_use_autosuspend(&dev->dev);
pm_runtime_put_noidle(&dev->dev);
pm_runtime_set_suspended(&dev->dev);
}
--
2.47.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 4/6] usb: typec: ucsi: ccg: add missing pm_runtime_dont_use_autosuspend() call
2026-09-15 9:02 [PATCH 0/6] usb: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
` (2 preceding siblings ...)
2026-09-15 9:02 ` [PATCH 3/6] usb: xhci: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
@ 2026-09-15 9:02 ` Joshua Crofts
2026-09-15 9:02 ` [PATCH 5/6] usb: mtu3: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
2026-09-15 9:02 ` [PATCH 6/6] usb: cdns3: add missing pm_runtime_dont_use_autosuspend() call Joshua Crofts
5 siblings, 0 replies; 14+ messages in thread
From: Joshua Crofts @ 2026-09-15 9:02 UTC (permalink / raw)
To: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Mathias Nyman, Chunfeng Yun, Matthias Brugger,
AngeloGioacchino Del Regno, Heikki Krogerus
Cc: linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek, stable
ucsi_ccg_remove() disables PM runtime on teardown, but doesn't call
pm_runtime_dont_use_autosuspend(), causing resource leaks.
Add the missing pm_runtime_dont_use_autosuspend() call.
Found using Coccinelle.
Fixes: a94ecde41f7e ("usb: typec: ucsi: ccg: enable runtime pm support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
drivers/usb/typec/ucsi/ucsi_ccg.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
index 91c2958a708c..9d3ebb255de7 100644
--- a/drivers/usb/typec/ucsi/ucsi_ccg.c
+++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
@@ -1519,6 +1519,7 @@ static void ucsi_ccg_remove(struct i2c_client *client)
cancel_work_sync(&uc->pm_work);
cancel_work_sync(&uc->work);
+ pm_runtime_dont_use_autosuspend(uc->dev);
pm_runtime_disable(uc->dev);
ucsi_unregister(uc->ucsi);
free_irq(uc->irq, uc);
--
2.47.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 5/6] usb: mtu3: add missing pm_runtime_dont_use_autosuspend() calls
2026-09-15 9:02 [PATCH 0/6] usb: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
` (3 preceding siblings ...)
2026-09-15 9:02 ` [PATCH 4/6] usb: typec: ucsi: ccg: add missing pm_runtime_dont_use_autosuspend() call Joshua Crofts
@ 2026-09-15 9:02 ` Joshua Crofts
2026-09-15 9:10 ` AngeloGioacchino Del Regno
2026-09-15 9:02 ` [PATCH 6/6] usb: cdns3: add missing pm_runtime_dont_use_autosuspend() call Joshua Crofts
5 siblings, 1 reply; 14+ messages in thread
From: Joshua Crofts @ 2026-09-15 9:02 UTC (permalink / raw)
To: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Mathias Nyman, Chunfeng Yun, Matthias Brugger,
AngeloGioacchino Del Regno, Heikki Krogerus
Cc: linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek, stable
The comm_init_err label in mtu3_probe() and mtu3_remove() both call
pm_runtime_disable() on error or device teardown, but don't call
pm_runtime_dont_use_autosuspend(), causing resource leaks.
Add the missing pm_runtime_dont_use_autosuspend().
Found using Coccinelle.
Fixes: df2069acb005 ("usb: Add MediaTek USB3 DRD driver")
Fixes: fa6f59e28c61 ("usb: mtu3: support runtime PM for host mode")
Cc: <stable@vger.kernel.org>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
drivers/usb/mtu3/mtu3_plat.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
index b4f4c776adb9..ce64c36a98f7 100644
--- a/drivers/usb/mtu3/mtu3_plat.c
+++ b/drivers/usb/mtu3/mtu3_plat.c
@@ -445,6 +445,7 @@ static int mtu3_probe(struct platform_device *pdev)
comm_init_err:
pm_runtime_put_noidle(dev);
pm_runtime_disable(dev);
+ pm_runtime_dont_use_autosuspend(dev);
ssusb_debugfs_remove_root(ssusb);
return ret;
@@ -483,6 +484,7 @@ static void mtu3_remove(struct platform_device *pdev)
ssusb_rscs_exit(ssusb);
ssusb_debugfs_remove_root(ssusb);
pm_runtime_disable(&pdev->dev);
+ pm_runtime_dont_use_autosuspend(&pdev->dev);
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
}
--
2.47.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 6/6] usb: cdns3: add missing pm_runtime_dont_use_autosuspend() call
2026-09-15 9:02 [PATCH 0/6] usb: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
` (4 preceding siblings ...)
2026-09-15 9:02 ` [PATCH 5/6] usb: mtu3: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
@ 2026-09-15 9:02 ` Joshua Crofts
5 siblings, 0 replies; 14+ messages in thread
From: Joshua Crofts @ 2026-09-15 9:02 UTC (permalink / raw)
To: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Mathias Nyman, Chunfeng Yun, Matthias Brugger,
AngeloGioacchino Del Regno, Heikki Krogerus
Cc: linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek, stable
cdns3_plat_remove() calls pm_runtime_disable() on device teardown, but
doesn't call pm_runtime_dont_use_autosuspend(), causing resource leaks.
Add the missing pm_runtime_dont_use_autosuspend() call.
Found using Coccinelle.
Fixes: f738957277ba ("usb: cdns3: Split core.c into cdns3-plat and core.c file")
Cc: <stable@vger.kernel.org>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
---
drivers/usb/cdns3/cdns3-plat.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/cdns3/cdns3-plat.c b/drivers/usb/cdns3/cdns3-plat.c
index e3f32c3e9535..b85d5d1c48fd 100644
--- a/drivers/usb/cdns3/cdns3-plat.c
+++ b/drivers/usb/cdns3/cdns3-plat.c
@@ -219,6 +219,7 @@ static void cdns3_plat_remove(struct platform_device *pdev)
if (!(cdns->pdata && (cdns->pdata->quirks & CDNS3_DEFAULT_PM_RUNTIME_ALLOW)))
pm_runtime_allow(dev);
+ pm_runtime_dont_use_autosuspend(dev);
pm_runtime_disable(dev);
pm_runtime_put_noidle(dev);
cdns_remove(cdns);
--
2.47.3
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/6] usb: xhci-mtk: add missing pm_runtime_dont_use_autosuspend() call
2026-09-15 9:02 ` [PATCH 2/6] usb: xhci-mtk: " Joshua Crofts
@ 2026-09-15 9:10 ` AngeloGioacchino Del Regno
2026-09-16 8:16 ` Johan Hovold
1 sibling, 0 replies; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-09-15 9:10 UTC (permalink / raw)
To: Joshua Crofts, Peter Chen, Pawel Laszczak, Roger Quadros,
Greg Kroah-Hartman, Mathias Nyman, Chunfeng Yun,
Matthias Brugger, Heikki Krogerus
Cc: linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek, stable
On 9/15/26 11:02, Joshua Crofts wrote:
> The disable_pm label in xhci_mtk_probe() and xhci_mtk_remove() both call
> pm_runtime_disable() on error or device teardown, but don't call
> pm_runtime_dont_use_autosuspend(), causing resource leaks.
>
> Add the missing pm_runtime_dont_use_autosuspend().
>
> Found using Coccinelle.
>
> Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host controller")
> Fixes: 04284eb74e0c ("usb: xhci-mtk: add support runtime PM")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/6] usb: mtu3: add missing pm_runtime_dont_use_autosuspend() calls
2026-09-15 9:02 ` [PATCH 5/6] usb: mtu3: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
@ 2026-09-15 9:10 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2026-09-15 9:10 UTC (permalink / raw)
To: Joshua Crofts, Peter Chen, Pawel Laszczak, Roger Quadros,
Greg Kroah-Hartman, Mathias Nyman, Chunfeng Yun,
Matthias Brugger, Heikki Krogerus
Cc: linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek, stable
On 9/15/26 11:02, Joshua Crofts wrote:
> The comm_init_err label in mtu3_probe() and mtu3_remove() both call
> pm_runtime_disable() on error or device teardown, but don't call
> pm_runtime_dont_use_autosuspend(), causing resource leaks.
>
> Add the missing pm_runtime_dont_use_autosuspend().
>
> Found using Coccinelle.
>
> Fixes: df2069acb005 ("usb: Add MediaTek USB3 DRD driver")
> Fixes: fa6f59e28c61 ("usb: mtu3: support runtime PM for host mode")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/6] usb: core: add missing pm_runtime_dont_use_autosuspend() call
2026-09-15 9:02 ` [PATCH 1/6] usb: core: add missing pm_runtime_dont_use_autosuspend() call Joshua Crofts
@ 2026-09-15 15:02 ` Alan Stern
2026-09-16 8:08 ` Johan Hovold
1 sibling, 0 replies; 14+ messages in thread
From: Alan Stern @ 2026-09-15 15:02 UTC (permalink / raw)
To: Joshua Crofts
Cc: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Mathias Nyman, Chunfeng Yun, Matthias Brugger,
AngeloGioacchino Del Regno, Heikki Krogerus, linux-usb,
linux-kernel, linux-arm-kernel, linux-mediatek, stable
On Tue, Sep 15, 2026 at 09:02:18AM +0000, Joshua Crofts wrote:
> The fail label in usb_new_device() disables pm_runtime on failure, but
> doesn't call pm_runtime_dont_use_autosuspend(), causing resource leaks.
>
> Add the missing pm_runtime_dont_use_autosuspend() call.
>
> Found using Coccinelle.
>
> Fixes: fcc4a01eb866 ("USB: use the runtime-PM autosuspend implementation")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
> ---
> drivers/usb/core/hub.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 3345b3298daf..dec6d5c49759 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -2745,6 +2745,7 @@ int usb_new_device(struct usb_device *udev)
> fail:
> usb_set_device_state(udev, USB_STATE_NOTATTACHED);
> pm_runtime_disable(&udev->dev);
> + pm_runtime_dont_use_autosuspend(&udev->dev);
> pm_runtime_set_suspended(&udev->dev);
> return err;
> }
> --
> 2.47.3
Acked-by: Alan Stern <stern@rowland.harvard.edu>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/6] usb: core: add missing pm_runtime_dont_use_autosuspend() call
2026-09-15 9:02 ` [PATCH 1/6] usb: core: add missing pm_runtime_dont_use_autosuspend() call Joshua Crofts
2026-09-15 15:02 ` Alan Stern
@ 2026-09-16 8:08 ` Johan Hovold
2026-09-16 8:21 ` Joshua Crofts
1 sibling, 1 reply; 14+ messages in thread
From: Johan Hovold @ 2026-09-16 8:08 UTC (permalink / raw)
To: Joshua Crofts
Cc: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Mathias Nyman, Chunfeng Yun, Matthias Brugger,
AngeloGioacchino Del Regno, Heikki Krogerus, linux-usb,
linux-kernel, linux-arm-kernel, linux-mediatek, stable
On Tue, Sep 15, 2026 at 09:02:18AM +0000, Joshua Crofts wrote:
> The fail label in usb_new_device() disables pm_runtime on failure, but
> doesn't call pm_runtime_dont_use_autosuspend(), causing resource leaks.
No it does not, as the device itself is about to be freed. Sure we could
disable autosuspend again here, but it does not really matter.
You could consider balancing the runtime pm count as well, as I guess
both of these could trip up static checkers (cf. [1]).
> Add the missing pm_runtime_dont_use_autosuspend() call.
>
> Found using Coccinelle.
>
> Fixes: fcc4a01eb866 ("USB: use the runtime-PM autosuspend implementation")
> Cc: <stable@vger.kernel.org>
But this one should not have a Fixes tag and does not need to be
backported.
> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
> ---
> drivers/usb/core/hub.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 3345b3298daf..dec6d5c49759 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -2745,6 +2745,7 @@ int usb_new_device(struct usb_device *udev)
> fail:
> usb_set_device_state(udev, USB_STATE_NOTATTACHED);
> pm_runtime_disable(&udev->dev);
> + pm_runtime_dont_use_autosuspend(&udev->dev);
> pm_runtime_set_suspended(&udev->dev);
> return err;
> }
Johan
[1] https://lore.kernel.org/all/aivMnTkZ-jTRH2Jy@hovoldconsulting.com/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/6] usb: xhci-mtk: add missing pm_runtime_dont_use_autosuspend() call
2026-09-15 9:02 ` [PATCH 2/6] usb: xhci-mtk: " Joshua Crofts
2026-09-15 9:10 ` AngeloGioacchino Del Regno
@ 2026-09-16 8:16 ` Johan Hovold
1 sibling, 0 replies; 14+ messages in thread
From: Johan Hovold @ 2026-09-16 8:16 UTC (permalink / raw)
To: Joshua Crofts
Cc: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Mathias Nyman, Chunfeng Yun, Matthias Brugger,
AngeloGioacchino Del Regno, Heikki Krogerus, linux-usb,
linux-kernel, linux-arm-kernel, linux-mediatek, stable
On Tue, Sep 15, 2026 at 09:02:19AM +0000, Joshua Crofts wrote:
> The disable_pm label in xhci_mtk_probe() and xhci_mtk_remove() both call
> pm_runtime_disable() on error or device teardown, but don't call
> pm_runtime_dont_use_autosuspend(), causing resource leaks.
No, there is no resource leak here either and this does not need to be
backported.
The autosuspend setting is not restored, but that would only possibly
have an impact in the theoretical corner case that someone forcibly
rebinds a different driver that does not enable it.
> Add the missing pm_runtime_dont_use_autosuspend().
>
> Found using Coccinelle.
>
> Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host controller")
> Fixes: 04284eb74e0c ("usb: xhci-mtk: add support runtime PM")
> Cc: <stable@vger.kernel.org>
So, without having looked at the rest: none of these should be
backported.
Johan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/6] usb: core: add missing pm_runtime_dont_use_autosuspend() call
2026-09-16 8:08 ` Johan Hovold
@ 2026-09-16 8:21 ` Joshua Crofts
2026-09-16 9:14 ` Johan Hovold
0 siblings, 1 reply; 14+ messages in thread
From: Joshua Crofts @ 2026-09-16 8:21 UTC (permalink / raw)
To: Johan Hovold
Cc: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Mathias Nyman, Chunfeng Yun, Matthias Brugger,
AngeloGioacchino Del Regno, Heikki Krogerus, linux-usb,
linux-kernel, linux-arm-kernel, linux-mediatek, stable
On Wed, 16 Sep 2026 10:08:52 +0200
Johan Hovold <johan@kernel.org> wrote:
> On Tue, Sep 15, 2026 at 09:02:18AM +0000, Joshua Crofts wrote:
> > The fail label in usb_new_device() disables pm_runtime on failure, but
> > doesn't call pm_runtime_dont_use_autosuspend(), causing resource leaks.
>
> No it does not, as the device itself is about to be freed. Sure we could
> disable autosuspend again here, but it does not really matter.
>
Okay, commit message aside, you still need to call dont_use_autosuspend()
on teardown as the driver doesn't use the devm_* counterparts. Currently
(according to my cocci SmPL [1]) there are 195 instances of this in the kernel.
...
> But this one should not have a Fixes tag and does not need to be
> backported.
Yeah, you already mentioned this in IIO once [2]. I found several instances
of patches like these being backported however, so perhaps times have changed.
[1] https://lore.kernel.org/cocci/20260915064327.1377-1-joshua.crofts1@gmail.com/
[2] https://lore.kernel.org/linux-iio/aoQEyeHUiTwWenBL@hovoldconsulting.com/
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/6] usb: core: add missing pm_runtime_dont_use_autosuspend() call
2026-09-16 8:21 ` Joshua Crofts
@ 2026-09-16 9:14 ` Johan Hovold
0 siblings, 0 replies; 14+ messages in thread
From: Johan Hovold @ 2026-09-16 9:14 UTC (permalink / raw)
To: Joshua Crofts
Cc: Peter Chen, Pawel Laszczak, Roger Quadros, Greg Kroah-Hartman,
Mathias Nyman, Chunfeng Yun, Matthias Brugger,
AngeloGioacchino Del Regno, Heikki Krogerus, linux-usb,
linux-kernel, linux-arm-kernel, linux-mediatek, stable
On Wed, Sep 16, 2026 at 10:21:32AM +0200, Joshua Crofts wrote:
> On Wed, 16 Sep 2026 10:08:52 +0200
> Johan Hovold <johan@kernel.org> wrote:
>
> > On Tue, Sep 15, 2026 at 09:02:18AM +0000, Joshua Crofts wrote:
> > > The fail label in usb_new_device() disables pm_runtime on failure, but
> > > doesn't call pm_runtime_dont_use_autosuspend(), causing resource leaks.
> >
> > No it does not, as the device itself is about to be freed. Sure we could
> > disable autosuspend again here, but it does not really matter.
> >
>
> Okay, commit message aside, you still need to call dont_use_autosuspend()
> on teardown as the driver doesn't use the devm_* counterparts.
No, you don't *need* to call it, but it is good practice to clean up
after yourself even for the theoretical corner case of someone forcibly
rebinding a different driver (which will soon also be tainting the
kernel).
But in this particular case (usb core) where all callers *free* the
device after the function returns it does not matter one bit.
> Currently
> (according to my cocci SmPL [1]) there are 195 instances of this in the kernel.
>
> ...
>
> > But this one should not have a Fixes tag and does not need to be
> > backported.
>
> Yeah, you already mentioned this in IIO once [2]. I found several instances
> of patches like these being backported however, so perhaps times have changed.
If you write a misleading commit message and add a CC stable tag,
chances are that a maintainer will miss this when reviewing and then
the commit gets backported.
That in no way means that you should continue doing so on purpose,
that's bordering willful deception.
Johan
> [1] https://lore.kernel.org/cocci/20260915064327.1377-1-joshua.crofts1@gmail.com/
> [2] https://lore.kernel.org/linux-iio/aoQEyeHUiTwWenBL@hovoldconsulting.com/
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-09-16 9:14 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15 9:02 [PATCH 0/6] usb: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
2026-09-15 9:02 ` [PATCH 1/6] usb: core: add missing pm_runtime_dont_use_autosuspend() call Joshua Crofts
2026-09-15 15:02 ` Alan Stern
2026-09-16 8:08 ` Johan Hovold
2026-09-16 8:21 ` Joshua Crofts
2026-09-16 9:14 ` Johan Hovold
2026-09-15 9:02 ` [PATCH 2/6] usb: xhci-mtk: " Joshua Crofts
2026-09-15 9:10 ` AngeloGioacchino Del Regno
2026-09-16 8:16 ` Johan Hovold
2026-09-15 9:02 ` [PATCH 3/6] usb: xhci: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
2026-09-15 9:02 ` [PATCH 4/6] usb: typec: ucsi: ccg: add missing pm_runtime_dont_use_autosuspend() call Joshua Crofts
2026-09-15 9:02 ` [PATCH 5/6] usb: mtu3: add missing pm_runtime_dont_use_autosuspend() calls Joshua Crofts
2026-09-15 9:10 ` AngeloGioacchino Del Regno
2026-09-15 9:02 ` [PATCH 6/6] usb: cdns3: add missing pm_runtime_dont_use_autosuspend() call Joshua Crofts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®