[PATCH] bus: ti-sysc: unregister notifier on driver register failure
From: Can Peng
Date: Tue Jul 28 2026 - 05:52:00 EST
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")
Signed-off-by: Can Peng <pengcan@xxxxxxxxxx>
---
drivers/bus/ti-sysc.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index e118b900c9ac..f960d29566e5 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -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);
--
2.53.0