Skip to content

Commit ac0cdb3

Browse files
Mao Wenangregkh
authored andcommitted
sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init()
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]>
1 parent 6734330 commit ac0cdb3

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
@@ -1507,18 +1507,26 @@ static int __init sc16is7xx_init(void)
15071507
ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver);
15081508
if (ret < 0) {
15091509
pr_err("failed to init sc16is7xx i2c --> %d\n", ret);
1510-
return ret;
1510+
goto err_i2c;
15111511
}
15121512
#endif
15131513

15141514
#ifdef CONFIG_SERIAL_SC16IS7XX_SPI
15151515
ret = spi_register_driver(&sc16is7xx_spi_uart_driver);
15161516
if (ret < 0) {
15171517
pr_err("failed to init sc16is7xx spi --> %d\n", ret);
1518-
return ret;
1518+
goto err_spi;
15191519
}
15201520
#endif
15211521
return ret;
1522+
1523+
err_spi:
1524+
#ifdef CONFIG_SERIAL_SC16IS7XX_I2C
1525+
i2c_del_driver(&sc16is7xx_i2c_uart_driver);
1526+
#endif
1527+
err_i2c:
1528+
uart_unregister_driver(&sc16is7xx_uart);
1529+
return ret;
15221530
}
15231531
module_init(sc16is7xx_init);
15241532

0 commit comments

Comments
 (0)