Skip to content

Commit 707615f

Browse files
Mao Wenangregkh
authored andcommitted
sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init()
[ Upstream commit ac0cdb3 ] Add the missing uart_unregister_driver() and i2c_del_driver() before return from sc16is7xx_init() in the error handling case. Signed-off-by: Mao Wenan <[email protected]> Reviewed-by: Vladimir Zapolskiy <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Sasha Levin (Microsoft) <[email protected]>
1 parent ae35822 commit 707615f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/tty/serial/sc16is7xx.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,18 +1483,26 @@ static int __init sc16is7xx_init(void)
14831483
ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver);
14841484
if (ret < 0) {
14851485
pr_err("failed to init sc16is7xx i2c --> %d\n", ret);
1486-
return ret;
1486+
goto err_i2c;
14871487
}
14881488
#endif
14891489

14901490
#ifdef CONFIG_SERIAL_SC16IS7XX_SPI
14911491
ret = spi_register_driver(&sc16is7xx_spi_uart_driver);
14921492
if (ret < 0) {
14931493
pr_err("failed to init sc16is7xx spi --> %d\n", ret);
1494-
return ret;
1494+
goto err_spi;
14951495
}
14961496
#endif
14971497
return ret;
1498+
1499+
err_spi:
1500+
#ifdef CONFIG_SERIAL_SC16IS7XX_I2C
1501+
i2c_del_driver(&sc16is7xx_i2c_uart_driver);
1502+
#endif
1503+
err_i2c:
1504+
uart_unregister_driver(&sc16is7xx_uart);
1505+
return ret;
14981506
}
14991507
module_init(sc16is7xx_init);
15001508

0 commit comments

Comments
 (0)