Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: serial: mpc5xxx: fix error handing in mpc52xx_uart_init()

Add the missing uart_unregister_driver() and uninit before return
from mpc52xx_uart_init() in the error handling case.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Wei Yongjun and committed by
Greg Kroah-Hartman
9bcc3278 a82ea439

+8 -3
+8 -3
drivers/tty/serial/mpc52xx_uart.c
··· 1497 1497 if (psc_ops && psc_ops->fifoc_init) { 1498 1498 ret = psc_ops->fifoc_init(); 1499 1499 if (ret) 1500 - return ret; 1500 + goto err_init; 1501 1501 } 1502 1502 1503 1503 ret = platform_driver_register(&mpc52xx_uart_of_driver); 1504 1504 if (ret) { 1505 1505 printk(KERN_ERR "%s: platform_driver_register failed (%i)\n", 1506 1506 __FILE__, ret); 1507 - uart_unregister_driver(&mpc52xx_uart_driver); 1508 - return ret; 1507 + goto err_reg; 1509 1508 } 1510 1509 1511 1510 return 0; 1511 + err_reg: 1512 + if (psc_ops && psc_ops->fifoc_uninit) 1513 + psc_ops->fifoc_uninit(); 1514 + err_init: 1515 + uart_unregister_driver(&mpc52xx_uart_driver); 1516 + return ret; 1512 1517 } 1513 1518 1514 1519 static void __exit