lkml.org 
[lkml]   [2021]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.4 103/133] hvsi: dont panic on tty_register_driver failure
    Date
    From: Jiri Slaby <jslaby@suse.cz>

    [ Upstream commit 7ccbdcc4d08a6d7041e4849219bbb12ffa45db4c ]

    The alloc_tty_driver failure is handled gracefully in hvsi_init. But
    tty_register_driver is not. panic is called if that one fails.

    So handle the failure of tty_register_driver gracefully too. This will
    keep at least the console functional as it was enabled earlier by
    console_initcall in hvsi_console_init. Instead of shooting down the
    whole system.

    This means, we disable interrupts and restore hvsi_wait back to
    poll_for_state().

    Cc: linuxppc-dev@lists.ozlabs.org
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Link: https://lore.kernel.org/r/20210723074317.32690-3-jslaby@suse.cz
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/tty/hvc/hvsi.c | 19 ++++++++++++++++---
    1 file changed, 16 insertions(+), 3 deletions(-)

    diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
    index a75146f600cb..3e29f5f0d4ca 100644
    --- a/drivers/tty/hvc/hvsi.c
    +++ b/drivers/tty/hvc/hvsi.c
    @@ -1051,7 +1051,7 @@ static const struct tty_operations hvsi_ops = {

    static int __init hvsi_init(void)
    {
    - int i;
    + int i, ret;

    hvsi_driver = alloc_tty_driver(hvsi_count);
    if (!hvsi_driver)
    @@ -1082,12 +1082,25 @@ static int __init hvsi_init(void)
    }
    hvsi_wait = wait_for_state; /* irqs active now */

    - if (tty_register_driver(hvsi_driver))
    - panic("Couldn't register hvsi console driver\n");
    + ret = tty_register_driver(hvsi_driver);
    + if (ret) {
    + pr_err("Couldn't register hvsi console driver\n");
    + goto err_free_irq;
    + }

    printk(KERN_DEBUG "HVSI: registered %i devices\n", hvsi_count);

    return 0;
    +err_free_irq:
    + hvsi_wait = poll_for_state;
    + for (i = 0; i < hvsi_count; i++) {
    + struct hvsi_struct *hp = &hvsi_ports[i];
    +
    + free_irq(hp->virq, hp);
    + }
    + tty_driver_kref_put(hvsi_driver);
    +
    + return ret;
    }
    device_initcall(hvsi_init);

    --
    2.30.2


    \
     
     \ /
      Last update: 2021-09-20 18:53    [W:5.782 / U:0.036 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site