drivers/usb/gadget/udc/renesas_usbf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
devm_pm_runtime_enable() can fail due to memory allocation.
The current code ignores its return value, potentially causing
pm_runtime_resume_and_get() to operate on uninitialized runtime
PM state.
Check the return value of devm_pm_runtime_enable() and return on failure.
Fixes: 3e6e14ffdea4 ("usb: gadget: udc: add Renesas RZ/N1 USBF controller support")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
drivers/usb/gadget/udc/renesas_usbf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/udc/renesas_usbf.c b/drivers/usb/gadget/udc/renesas_usbf.c
index 14f4b2cf05a4..4c201574a0af 100644
--- a/drivers/usb/gadget/udc/renesas_usbf.c
+++ b/drivers/usb/gadget/udc/renesas_usbf.c
@@ -3262,7 +3262,9 @@ static int usbf_probe(struct platform_device *pdev)
if (IS_ERR(udc->regs))
return PTR_ERR(udc->regs);
- devm_pm_runtime_enable(&pdev->dev);
+ ret = devm_pm_runtime_enable(&pdev->dev);
+ if (ret)
+ return ret;
ret = pm_runtime_resume_and_get(&pdev->dev);
if (ret < 0)
return ret;
--
2.50.1.windows.1
Hi Haotian,
On Mon, 24 Nov 2025 at 03:24, Haotian Zhang <vulab@iscas.ac.cn> wrote:
> devm_pm_runtime_enable() can fail due to memory allocation.
> The current code ignores its return value, potentially causing
> pm_runtime_resume_and_get() to operate on uninitialized runtime
> PM state.
>
> Check the return value of devm_pm_runtime_enable() and return on failure.
>
> Fixes: 3e6e14ffdea4 ("usb: gadget: udc: add Renesas RZ/N1 USBF controller support")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Thanks for your patch!
> --- a/drivers/usb/gadget/udc/renesas_usbf.c
> +++ b/drivers/usb/gadget/udc/renesas_usbf.c
> @@ -3262,7 +3262,9 @@ static int usbf_probe(struct platform_device *pdev)
> if (IS_ERR(udc->regs))
> return PTR_ERR(udc->regs);
>
> - devm_pm_runtime_enable(&pdev->dev);
> + ret = devm_pm_runtime_enable(&pdev->dev);
> + if (ret)
> + return ret;
Perhaps insert a blank line here?
> ret = pm_runtime_resume_and_get(&pdev->dev);
> if (ret < 0)
> return ret;
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
On Mon, Nov 24, 2025 at 02:15:14PM +0100, Geert Uytterhoeven wrote: > On Mon, 24 Nov 2025 at 03:24, Haotian Zhang <vulab@iscas.ac.cn> wrote: > Thanks for your patch! ... > > - devm_pm_runtime_enable(&pdev->dev); > > + ret = devm_pm_runtime_enable(&pdev->dev); > > + if (ret) > > + return ret; > > Perhaps insert a blank line here? > > > ret = pm_runtime_resume_and_get(&pdev->dev); > > if (ret < 0) > > return ret; FWIW, if not fixed yet, this driver from this line towards the end of the function leaks the PM runtime reference count. > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> -- With Best Regards, Andy Shevchenko
Hi Haotian,
On Mon, 24 Nov 2025 10:22:15 +0800
Haotian Zhang <vulab@iscas.ac.cn> wrote:
> devm_pm_runtime_enable() can fail due to memory allocation.
> The current code ignores its return value, potentially causing
> pm_runtime_resume_and_get() to operate on uninitialized runtime
> PM state.
>
> Check the return value of devm_pm_runtime_enable() and return on failure.
>
> Fixes: 3e6e14ffdea4 ("usb: gadget: udc: add Renesas RZ/N1 USBF controller support")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Thanks for the patch.
Acked-by: Herve Codina <herve.codina@bootlin.com>
Best regards,
Hervé
© 2016 - 2025 Red Hat, Inc.