Re: [PATCH] usb: gadget: renesas_usbf: Handle devm_pm_runtime_enable() errors

From: Geert Uytterhoeven

Date: Mon Nov 24 2025 - 08:15:36 EST


Hi Haotian,

On Mon, 24 Nov 2025 at 03:24, Haotian Zhang <vulab@xxxxxxxxxxx> 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@xxxxxxxxxxx>

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@xxxxxxxxx>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

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