Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2567755lkm; Mon, 20 Sep 2021 18:55:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUUkxBNIBscxcfgfgLJHrMRYCDb/M2XfliuFq1eBLqgh9hzxCT1VY0nkohI4cD+9YAtXLX X-Received: by 2002:a17:906:585a:: with SMTP id h26mr31733570ejs.31.1632189338107; Mon, 20 Sep 2021 18:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632189338; cv=none; d=google.com; s=arc-20160816; b=LbXJB2lCB0r8Lgh48DzcfAQnPQEaWuBbdjguu0+w54KlqOgKC6kMC+3q2IAeFVPSf3 tdxDoDERL0AtXeu4VrjHTjVAFGSeUnaNm+TpYpkQe4t5WAQXIhdX9ZNtnMW6kMMUrq+a UgjrutLc+beu5ViUqDrmYMN7VeUUbjN/DzZ4xAFuS+SXUvpDj7rDzSqOV7GE4UygG80i OKt35nTNzMg+Ow+z2cdY2645i2XYV371W8BIUN4fRhZfi6YdHAyVnEzo/64F1vPHBFv2 clUWmS6ABcmxoqdsRzGMyzvtASnq/ku253ujsfJC0SygVt0f/WZsY0Hq2CwnI9vaY8p1 KVZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kvL9ZQ3aJHKJdvZinIT8wRUFi9Wkduu9m//lDrK0gOM=; b=BCXra5Bm+3glF6DYL4OPV4Toc3JJ2yQv1LMxz4CvOoqq6sjCcC7/M1oTwYYSv3LqQZ UF4ddzjHXbK9lkCWhskBT5FfCKk7Q0FiISxfiAGdxfkxA7U2BBQXNpeJJyryM0XEwpk6 krY4s6EwjCM4rIbudRvpvax2QqhfOEiRkSeGLHFhAaaDNi/qDyIYTaMnzQUAr9G02J52 hx/gO0SSeUzuatRg0GbjvtRkaHuSvD3XSxXERWdv259v5PM4NVdps2cRcjOg0IQH4pDS sNibW9kj/WMSDkIKMRpb6MVoU/A+4GaglnYlHBg45PknDsHaN2l4hYytTqRo0ts7hiOg ztdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bRniLHjc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k1si6869526edr.250.2021.09.20.18.55.14; Mon, 20 Sep 2021 18:55:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bRniLHjc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376995AbhITSPC (ORCPT + 99 others); Mon, 20 Sep 2021 14:15:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:33262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356376AbhITSIq (ORCPT ); Mon, 20 Sep 2021 14:08:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D9CA63259; Mon, 20 Sep 2021 17:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158332; bh=v6+CyDVCHXj4E1pUKK8Z0p2O+fCTC4zZOPVHoRbrJqc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bRniLHjc6mVZQWIuRwYMBneuQvktxOLNpUXDZRYpCGzU9h5bU8Kcu+ygpQEDejprB AxgGSRAY4GGmbJUwL9BIMcbXkXWjs/d7/ucoZ8Ge+KrV7e0g0FE4NyD0/wglzRbA2i ofWv3hJlaUi7TeGeIBJcF6VkIX6waUMelR4gNulg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Jiri Slaby , Sasha Levin Subject: [PATCH 5.4 107/260] hvsi: dont panic on tty_register_driver failure Date: Mon, 20 Sep 2021 18:42:05 +0200 Message-Id: <20210920163934.764717696@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Slaby [ 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 Link: https://lore.kernel.org/r/20210723074317.32690-3-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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 66f95f758be0..73226337f561 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c @@ -1038,7 +1038,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) @@ -1069,12 +1069,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