Skip to contentSkip to conversation

bus: sunxi-rsb: Fix error handling in sunxi_rsb_init()

PATCH Applied Yuan Can 2 participants 3 messages Nov 23, 2022 – Jan 8, 2023 Arm/Allwinner sunXi SoC support

lore
Share & tools
lore

Yuan Can

author
#0 lore raw

PATCH 1/1 bus: sunxi-rsb: Fix error handling in sunxi_rsb_init()

The sunxi_rsb_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, the sunxi_rsb_bus is not unregistered.
Fix by unregister sunxi_rsb_bus when platform_driver_register() failed.

Fixes d787dcdb9c8f ("bus: sunxi-rsb: Add driver for Allwinner Reduced Serial Bus")
---
 drivers/bus/sunxi-rsb.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/bus/sunxi-rsb.c +7 -1
index 4cd2e127946e..87b10011667c 100644
@@ -853,7 +853,13 @@ static int __init sunxi_rsb_init(void)
 		return ret;
 	}
 
-	return platform_driver_register(&sunxi_rsb_driver);
+	ret = platform_driver_register(&sunxi_rsb_driver);
+	if (ret) {
+		bus_unregister(&sunxi_rsb_bus);
+		return ret;
+	}
+
+	return 0;
 }
 module_init(sunxi_rsb_init);
 
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Dne sreda, 23. november 2022 ob 10:42:00 CET je Yuan Can napisal(a):

Quoted 7 lines

The sunxi_rsb_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, the sunxi_rsb_bus is not unregistered.
Fix by unregister sunxi_rsb_bus when platform_driver_register() failed.

Fixes d787dcdb9c8f ("bus: sunxi-rsb: Add driver for Allwinner Reduced

Serial Bus") Signed-off-by: Yuan Can <[email protected]>

Best regards,
Jernej

maintainer Applied
#2 lore raw
In reply to Yuan Can

Dne sreda, 23. november 2022 ob 10:42:00 CET je Yuan Can napisal(a):

Quoted 7 lines

The sunxi_rsb_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, the sunxi_rsb_bus is not unregistered.
Fix by unregister sunxi_rsb_bus when platform_driver_register() failed.

Fixes d787dcdb9c8f ("bus: sunxi-rsb: Add driver for Allwinner Reduced

Serial Bus") Signed-off-by: Yuan Can <[email protected]>

Applied, thanks!

Best regards,
Jernej