]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/sc16is7xx-missing-unregister-delete-driver-on-error-.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.4 / sc16is7xx-missing-unregister-delete-driver-on-error-.patch
1 From eee2c6316c5a769cb3d0ea6f877fe9b2b76bbf50 Mon Sep 17 00:00:00 2001
2 From: Mao Wenan <maowenan@huawei.com>
3 Date: Fri, 8 Mar 2019 22:08:31 +0800
4 Subject: sc16is7xx: missing unregister/delete driver on error in
5 sc16is7xx_init()
6
7 [ Upstream commit ac0cdb3d990108df795b676cd0d0e65ac34b2273 ]
8
9 Add the missing uart_unregister_driver() and i2c_del_driver() before return
10 from sc16is7xx_init() in the error handling case.
11
12 Signed-off-by: Mao Wenan <maowenan@huawei.com>
13 Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
14 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
15 Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
16 ---
17 drivers/tty/serial/sc16is7xx.c | 12 ++++++++++--
18 1 file changed, 10 insertions(+), 2 deletions(-)
19
20 diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
21 index 17a22073d226..032f3c13b8c4 100644
22 --- a/drivers/tty/serial/sc16is7xx.c
23 +++ b/drivers/tty/serial/sc16is7xx.c
24 @@ -1448,7 +1448,7 @@ static int __init sc16is7xx_init(void)
25 ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver);
26 if (ret < 0) {
27 pr_err("failed to init sc16is7xx i2c --> %d\n", ret);
28 - return ret;
29 + goto err_i2c;
30 }
31 #endif
32
33 @@ -1456,10 +1456,18 @@ static int __init sc16is7xx_init(void)
34 ret = spi_register_driver(&sc16is7xx_spi_uart_driver);
35 if (ret < 0) {
36 pr_err("failed to init sc16is7xx spi --> %d\n", ret);
37 - return ret;
38 + goto err_spi;
39 }
40 #endif
41 return ret;
42 +
43 +err_spi:
44 +#ifdef CONFIG_SERIAL_SC16IS7XX_I2C
45 + i2c_del_driver(&sc16is7xx_i2c_uart_driver);
46 +#endif
47 +err_i2c:
48 + uart_unregister_driver(&sc16is7xx_uart);
49 + return ret;
50 }
51 module_init(sc16is7xx_init);
52
53 --
54 2.19.1
55