summaryrefslogtreecommitdiff
path: root/drivers/bus
diff options
context:
space:
mode:
authorYuan Can <yuancan@huawei.com>2022-11-23 12:42:00 +0300
committerJernej Skrabec <jernej.skrabec@gmail.com>2023-01-08 23:35:01 +0300
commitf71eaf2708be7831428eacae7db25d8ec6b8b4c5 (patch)
tree08f0eb042be5d5d8cd47be44148d49fba7105d30 /drivers/bus
parent1b929c02afd37871d5afb9d498426f83432e71c2 (diff)
downloadlinux-f71eaf2708be7831428eacae7db25d8ec6b8b4c5.tar.xz
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") Signed-off-by: Yuan Can <yuancan@huawei.com> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com> Link: https://lore.kernel.org/r/20221123094200.12036-1-yuancan@huawei.com Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Diffstat (limited to 'drivers/bus')
-rw-r--r--drivers/bus/sunxi-rsb.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c
index 3aa91aed3bf7..226e87b85116 100644
--- a/drivers/bus/sunxi-rsb.c
+++ b/drivers/bus/sunxi-rsb.c
@@ -857,7 +857,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);