Message ID | 20221124031932.17032-1-yuancan@huawei.com |
---|---|
State | Accepted |
Commit | c4d33381b134da188ccd1084aef21e2b8c3c422e |
Headers | show |
Series | power: supply: ab8500: Fix error handling in ab8500_charger_init() | expand |
Hi, On Thu, Nov 24, 2022 at 03:19:32AM +0000, Yuan Can wrote: > 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: 1c1f13a006ed ("power: supply: ab8500: Move to componentized binding") > Signed-off-by: Yuan Can <yuancan@huawei.com> > --- Thanks, queued. -- Sebastian > drivers/power/supply/ab8500_charger.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c > index c19c50442761..58757a5799f8 100644 > --- a/drivers/power/supply/ab8500_charger.c > +++ b/drivers/power/supply/ab8500_charger.c > @@ -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) > -- > 2.17.1 >
diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c index c19c50442761..58757a5799f8 100644 --- a/drivers/power/supply/ab8500_charger.c +++ b/drivers/power/supply/ab8500_charger.c @@ -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)
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: 1c1f13a006ed ("power: supply: ab8500: Move to componentized binding") Signed-off-by: Yuan Can <yuancan@huawei.com> --- drivers/power/supply/ab8500_charger.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)