summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2021-07-23 10:43:10 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-09-18 14:42:05 +0300
commitdbec7128bfbc962daba087c15d17d6eb4d812636 (patch)
tree3d0f0bd59b019b38705a850beab12cd50f2ee693 /arch
parent9d4d43f83f415468afa9a95ac847f84e4fe5505a (diff)
downloadlinux-dbec7128bfbc962daba087c15d17d6eb4d812636.tar.xz
xtensa: ISS: don't panic in rs_init
[ Upstream commit 23411c720052ad860b3e579ee4873511e367130a ] While alloc_tty_driver failure in rs_init would mean we have much bigger problem, there is no reason to panic when tty_register_driver fails there. It can fail for various reasons. So handle the failure gracefully. Actually handle them both while at it. This will make at least the console functional as it was enabled earlier by console_initcall in iss_console_init. Instead of shooting down the whole system. We move tty_port_init() after alloc_tty_driver(), so that we don't need to destroy the port in case the latter function fails. Cc: Chris Zankel <chris@zankel.net> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: linux-xtensa@linux-xtensa.org Acked-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210723074317.32690-2-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/xtensa/platforms/iss/console.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index a3dda25a4e45..eed02cf3d6b0 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -143,9 +143,13 @@ static const struct tty_operations serial_ops = {
static int __init rs_init(void)
{
- tty_port_init(&serial_port);
+ int ret;
serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES);
+ if (!serial_driver)
+ return -ENOMEM;
+
+ tty_port_init(&serial_port);
/* Initialize the tty_driver structure */
@@ -163,8 +167,15 @@ static int __init rs_init(void)
tty_set_operations(serial_driver, &serial_ops);
tty_port_link_device(&serial_port, serial_driver, 0);
- if (tty_register_driver(serial_driver))
- panic("Couldn't register serial driver\n");
+ ret = tty_register_driver(serial_driver);
+ if (ret) {
+ pr_err("Couldn't register serial driver\n");
+ tty_driver_kref_put(serial_driver);
+ tty_port_destroy(&serial_port);
+
+ return ret;
+ }
+
return 0;
}