bus: ti-sysc: unregister notifier on driver register failure
PATCH 1/1 bus: ti-sysc: unregister notifier on driver register failure
sysc_init() registers the platform bus notifier before registering the platform driver. If platform_driver_register() fails, the function returns the error directly and leaves the notifier registered.
Mirror the exit path on this failure by unregistering the notifier before returning the error. Also check and return the notifier registration error instead of continuing without the notifier installed.
--- drivers/bus/ti-sysc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/bus/ti-sysc.c +10 -2
@@ -3333,9 +3333,17 @@ static struct platform_driver sysc_driver = {static int __init sysc_init (void ) { -bus_register_notifier (&platform_bus_type, &sysc_nb); +int error; + + error =bus_register_notifier (&platform_bus_type, &sysc_nb); +if (error) +return error; -return platform_driver_register (&sysc_driver); + error =platform_driver_register (&sysc_driver); +if (error) +bus_unregister_notifier (&platform_bus_type, &sysc_nb); + +return error; }module_init (sysc_init);
Signature · 1 line
2.53.0
Quoted 9 lines · Can Peng
sysc_init()registers the platform bus notifier before registering the platform driver. Ifplatform_driver_register()fails, the function returns the error directly and leaves the notifier registered.Mirror the exit path on this failure by unregistering the notifier before returning the error. Also check and return the notifier registration error instead of continuing without the notifier installed.
[...]
Applied, thanks!
[1/1] bus: ti-sysc: unregister notifier on driver register failure
(no commit info)
Best regards,
Signature · 1 line
Kevin Hilman (TI) <[email protected]>