Skip to content

Commit

Permalink
serial: max310x: unregister uart driver in case of failure and abort
Browse files Browse the repository at this point in the history
[ Upstream commit 3890e3d ]

The macro "spi_register_driver" invokes the function
"__spi_register_driver()" which has a return type of int and can fail,
returning a negative value in such a case. This is currently ignored and
the init() function yields success even if the spi driver failed to
register.

Fix this by collecting the return value of "__spi_register_driver()" and
also unregister the uart driver in case of failure.

Cc: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Atul Gopinathan <atulgopinathan@gmail.com>
Link: https://lore.kernel.org/r/20210503115736.2104747-12-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
atul-g authored and gregkh committed Jun 3, 2021
1 parent 436fbcb commit e1fa6f4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/tty/serial/max310x.c
Expand Up @@ -1518,10 +1518,12 @@ static int __init max310x_uart_init(void)
return ret;

#ifdef CONFIG_SPI_MASTER
spi_register_driver(&max310x_spi_driver);
ret = spi_register_driver(&max310x_spi_driver);
if (ret)
uart_unregister_driver(&max310x_uart);
#endif

return 0;
return ret;
}
module_init(max310x_uart_init);

Expand Down

0 comments on commit e1fa6f4

Please sign in to comment.