[PATCH] serial: clps711x: Fix error handling in uart_clps711x_init()
Yuan Can
yuancan at huawei.com
Wed Nov 23 22:12:36 PST 2022
The uart_clps711x_init() returns the platform_driver_register() directly
without checking its return value, if platform_driver_register() failed,
the clps711x_uart is not unregistered.
Fix by unregister clps711x_uart when platform_driver_register() failed.
Fixes: bc00024502ed ("serial: clps711x: Driver refactor")
Signed-off-by: Yuan Can <yuancan at huawei.com>
---
drivers/tty/serial/clps711x.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c
index 404b43a5ae33..d6284244da1d 100644
--- a/drivers/tty/serial/clps711x.c
+++ b/drivers/tty/serial/clps711x.c
@@ -546,7 +546,13 @@ static int __init uart_clps711x_init(void)
if (ret)
return ret;
- return platform_driver_register(&clps711x_uart_platform);
+ ret = platform_driver_register(&clps711x_uart_platform);
+ if (ret) {
+ uart_unregister_driver(&clps711x_uart);
+ return ret;
+ }
+
+ return 0;
}
module_init(uart_clps711x_init);
--
2.17.1
More information about the linux-arm-kernel
mailing list