[PATCH] gpio: mxc: Register syscore callbacks after the platform driver

Tian Xuechen 202300460064 at mail.sdu.edu.cn
Fri Nov 27 03:33:31 PST 2026


From: Tian Xuechen <202300460064 at mail.sdu.edu.cn>

If platform driver registration fails, module initialization returns an
error with the syscore callbacks still registered. Register the
callbacks only after the driver has been registered successfully.

This issue was found by our static analysis tool under development.

Fixes: 1a5287a3dbc3 ("gpio: mxc: move gpio noirq suspend/resume to syscore phase")
Signed-off-by: Tian Xuechen <202300460064 at mail.sdu.edu.cn>
---
 drivers/gpio/gpio-mxc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 7dabe8073dc6..ed79ce76dcf3 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -738,9 +738,14 @@ static struct platform_driver mxc_gpio_driver = {
 
 static int __init gpio_mxc_init(void)
 {
-	register_syscore(&mxc_gpio_syscore);
+	int ret;
 
-	return platform_driver_register(&mxc_gpio_driver);
+	ret = platform_driver_register(&mxc_gpio_driver);
+	if (ret)
+		return ret;
+
+	register_syscore(&mxc_gpio_syscore);
+	return 0;
 }
 subsys_initcall(gpio_mxc_init);
 

base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5
-- 
2.43.0




More information about the linux-arm-kernel mailing list