staging: greybus: arche-platform: fix pm_notifier leak in probe error path
Subsystems (3)
PATCH 1/1 staging: greybus: arche-platform: fix pm_notifier leak in probe error path
In arche_platform_probe(), if arche_platform_coldboot_seq() fails after register_pm_notifier() succeeds, the function returns without unregistering the pm_notifier, leading to a resource leak.
Add unregister_pm_notifier() call in the err_coldboot error path to properly clean up the registered notifier on failure.
--- drivers/staging/greybus/arche-platform.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/greybus/arche-platform.c +1 -0
@@ -545,6 +545,7 @@ static int arche_platform_probe(struct platform_device *pdev)return 0 ; err_coldboot: +unregister_pm_notifier (&arche_pdata->pm_notifier);mutex_unlock (&arche_pdata->platform_state_mutex); err_device_remove:device_remove_file (&pdev->dev, &dev_attr_state);
Signature · 1 line
2.50.1.windows.1
Johan Hovold
maintainerQuoted 18 lines · Haotian Zhang
In
arche_platform_probe(), ifarche_platform_coldboot_seq()fails afterregister_pm_notifier()succeeds, the function returns without unregistering thepm_notifier, leading to a resource leak.Add
unregister_pm_notifier()call in theerr_coldbooterror path to properly clean up the registered notifier on failure.Fixes d29b67d44a7c ("greybus: arche-platform: Add support for init-off feature")Signed-off-by Haotian Zhang <[email protected]>--- drivers/staging/greybus/arche-platform.c | 1 + 1 file changed, 1 insertion(+)drivers/staging/greybus/arche-platform.c +0
-0
drivers/staging/greybus/arche-platform.c static int arche_platform_probe(struct platform_device *pdev) · line 549
Quoted 5 lines
drivers/staging/greybus/arche-platform.c +1
-0@@ -545,6 +545,7 @@ static int arche_platform_probe(struct platform_device *pdev)return 0 ; err_coldboot: +unregister_pm_notifier (&arche_pdata->pm_notifier);mutex_unlock (&arche_pdata->platform_state_mutex);
This looks mostly correct, but please make sure to release the lock before deregistering the notifier so that things are unwound in reverse order.
It would be even better to move the mutex unlock to where the driver jumps to err_coldboot since it is only held in that conditional since the offending commit.
drivers/staging/greybus/arche-platform.c static int arche_platform_probe(struct platform_device *pdev) · line 551
Quoted 2 lines
drivers/staging/greybus/arche-platform.c +0
-0err_device_remove:device_remove_file (&pdev->dev, &dev_attr_state);
Johan