[PATCH] can: flexcan: fix runtime PM reference imbalance on probe failure
From: Guangshuo Li
Date: Tue Sep 15 2026 - 13:03:50 EST
flexcan_probe() increments the runtime PM usage counter with
pm_runtime_get_noresume() before registering the CAN device.
On successful registration, register_flexcandev() drops this reference
with pm_runtime_put(). However, if flexcan_setup_stop_mode() subsequently
fails, the error path unregisters the CAN device and falls through to
failed_register, where pm_runtime_put_noidle() drops the same reference
again.
This results in an unbalanced runtime PM usage counter on the stop mode
setup failure path.
Skip pm_runtime_put_noidle() after a successful register_flexcandev()
and only disable runtime PM before freeing the CAN device.
This issue was found by manual code inspection.
Fixes: 812f0116c66a ("can: flexcan: add CAN wakeup function for i.MX8QM")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Guangshuo Li <lgs201920130244@xxxxxxxxx>
---
drivers/net/can/flexcan/flexcan-core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
index f5d22c61503f..7d675696797f 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -2266,8 +2266,10 @@ static int flexcan_probe(struct platform_device *pdev)
failed_setup_stop_mode:
unregister_flexcandev(dev);
+ goto failed_pm_runtime_disable;
failed_register:
pm_runtime_put_noidle(&pdev->dev);
+failed_pm_runtime_disable:
pm_runtime_disable(&pdev->dev);
failed_platform_get_irq:
free_candev(dev);
--
2.43.0