Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1562046pxb; Thu, 16 Sep 2021 09:57:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylF+++ST+O49B8EFkxt6hjkwKEX0ynh4oD9FdjbP0QpLCER35hsRpDTxB4iSSelty9IxZA X-Received: by 2002:a17:906:c205:: with SMTP id d5mr7441045ejz.74.1631811452163; Thu, 16 Sep 2021 09:57:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631811452; cv=none; d=google.com; s=arc-20160816; b=zzT/V6mRLvKxO+Low+vNbBNB3ovkfSji6A68RLY+vYkLC4vdthUsOcjOZh7Q2QGD+G 9cxAS3TQTqbTiOIVE00HgcZcRaCQlKBF7sMSXgOvgrpRTmz6ipBD/flV3yqP4pAKkhGF bsYNN1gb+1EQFEOgzKNXxubLDmeiiIX4GIVr37+NGnbOX7TDBLLDI6iOkyBK02UmwuCp KeP5kWWOgdVPYQ/CbiKybtw2ref+rsGH+oakSDvGY0XjK5wsCEFOAjbpEktTd/tsRtVw 8QdjgN+jkFSwkTX4G4MWqo0oecqvLYf8eAZnPZtLjIaYhuwA0vvPbTRNBbXyuu0kSYte bfng== 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=jyR36cxi7wy8ak4UEFH/q8IXHICJbw7vBvogJKPOz2w=; b=OdoqN8JgSHPf+5sHDM+tOWuIthApsUmWBTTNevzeGtIN27nyStlKskdT9BfsOF/P58 nkkbFdssxkX6c62YfF+KO7TSjMRgGr0qQ9s3Qq5Kl9LRvmot5b2W7gOnPcYzF5cEzCrm jbQjhHOPCoTOVLqbEb4kjsRLfldWwGNb/neDhyGocSIHfAb8P6vxSlc/boyW8n9dfxH/ ffxpJIAGk2Aj4qiGSEVV1i+EQrF/8pClO04pDjxcYjqMUMP49i/ZsN85p6iM8gc0iu6h iahciITdpE1GmNQhSy+tq5pJI/GdAjHAvlvsewkd07avDa99CBwG/0vKfW3RDlsGWqzD W3+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="n+fu/LTs"; 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 au25si5298446ejc.360.2021.09.16.09.57.06; Thu, 16 Sep 2021 09:57:32 -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="n+fu/LTs"; 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 S245083AbhIPQxq (ORCPT + 99 others); Thu, 16 Sep 2021 12:53:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:59260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344486AbhIPQqF (ORCPT ); Thu, 16 Sep 2021 12:46:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 874CD61269; Thu, 16 Sep 2021 16:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809580; bh=HJZadhkc3lcjE7AapxAuKY6kRDDcL5N6KsyajWYJPs4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n+fu/LTsY4u5CM9PiD1tXSqusLN2bSQ+xdtIVfb5Bmw+YeN28ORzowB61UavB/Psc EHqO5G5tEh8UzfrFD4PzgXBBrM4LEoutHKqQCuawiuaC6fFRWvpY9UFh8pSUDd/K/9 5G8b6jmtH4/DvbM5+Hq8Ap/5NfDHBnL8RSCX6p0k= 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.13 205/380] hvsi: dont panic on tty_register_driver failure Date: Thu, 16 Sep 2021 17:59:22 +0200 Message-Id: <20210916155811.041705800@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@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 e8c58f9bd263..d6afaae1729a 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