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 <miaoqingl...@huawei.com>
---
 drivers/tty/serial/serial_txx9.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

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:
-- 
2.23.0

Reply via email to