Skip to content

Commit c4d3338

Browse files
Yuan Cansre
authored andcommitted
power: supply: ab8500: Fix error handling in ab8500_charger_init()
The ab8500_charger_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, all ab8500_charger_component_drivers are not unregistered. Fix by unregister ab8500_charger_component_drivers when platform_driver_register() failed. Fixes: 1c1f13a ("power: supply: ab8500: Move to componentized binding") Signed-off-by: Yuan Can <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 97f2b4d commit c4d3338

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/power/supply/ab8500_charger.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3719,7 +3719,14 @@ static int __init ab8500_charger_init(void)
37193719
if (ret)
37203720
return ret;
37213721

3722-
return platform_driver_register(&ab8500_charger_driver);
3722+
ret = platform_driver_register(&ab8500_charger_driver);
3723+
if (ret) {
3724+
platform_unregister_drivers(ab8500_charger_component_drivers,
3725+
ARRAY_SIZE(ab8500_charger_component_drivers));
3726+
return ret;
3727+
}
3728+
3729+
return 0;
37233730
}
37243731

37253732
static void __exit ab8500_charger_exit(void)

0 commit comments

Comments
 (0)