[PATCH] serial: clps711x: Fix error handling in uart_clps711x_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux