Skip to contentSkip to conversation

bus: ti-sysc: unregister notifier on driver register failure

PATCH Applied Can Peng 2 participants 2 messages Jul 28 – Aug 31 OMAP2+ support

lore
Share & tools
lore

Can Peng

author
#0 lore raw

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.

Fixes 2c355ff6b6ca ("bus: ti-sysc: Add fck clock alias for children with notifier_block")
---
 drivers/bus/ti-sysc.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/bus/ti-sysc.c +10 -2
index e118b900c9ac..f960d29566e5 100644
@@ -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
maintainer Applied
#1 lore raw
Quoted 9 lines · Can Peng

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.

[...]

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]>