Commit c4d33381 authored by Yuan Can's avatar Yuan Can Committed by Sebastian Reichel

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: 1c1f13a0 ("power: supply: ab8500: Move to componentized binding")
Signed-off-by: default avatarYuan Can <yuancan@huawei.com>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 97f2b4dd
......@@ -3719,7 +3719,14 @@ static int __init ab8500_charger_init(void)
if (ret)
return ret;
return platform_driver_register(&ab8500_charger_driver);
ret = platform_driver_register(&ab8500_charger_driver);
if (ret) {
platform_unregister_drivers(ab8500_charger_component_drivers,
ARRAY_SIZE(ab8500_charger_component_drivers));
return ret;
}
return 0;
}
static void __exit ab8500_charger_exit(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment