serial: txx9: add missing platform_driver_unregister() on error in serial_txx9_init
diff mbox series

Message ID 20201031011857.137352-1-miaoqinglang@huawei.com
State New
Headers show
Series
  • serial: txx9: add missing platform_driver_unregister() on error in serial_txx9_init
Related show

Commit Message

Qinglang Miao Oct. 31, 2020, 1:18 a.m. UTC
Add the missing platform_driver_unregister() before return
from serial_txx9_init in the error handling case when failed
to register serial_txx9_pci_driver with macro ENABLE_SERIAL_TXX9_PCI
defined.

Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
 drivers/tty/serial/serial_txx9.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
index b4d89e317..3d883cd55 100644
--- a/drivers/tty/serial/serial_txx9.c
+++ b/drivers/tty/serial/serial_txx9.c
@@ -1280,10 +1280,13 @@  static int __init serial_txx9_init(void)
 
 #ifdef ENABLE_SERIAL_TXX9_PCI
 	ret = pci_register_driver(&serial_txx9_pci_driver);
+	if (ret)
+		goto unreg_platform_drv;
 #endif
-	if (ret == 0)
-		goto out;
+	return 0;
 
+ unreg_platform_drv:
+	platform_driver_unregister(&serial_txx9_plat_driver);
  del_dev:
 	platform_device_del(serial_txx9_plat_devs);
  put_dev: