Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2565672lkm; Mon, 20 Sep 2021 18:52:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+fF0Ny34EEY6QQHbt4OT9mWeIASUOLeauA7okmVpJViuv2e316qj+9oe9ZknG8v79OmOT X-Received: by 2002:a5e:a904:: with SMTP id c4mr1725843iod.14.1632189016490; Mon, 20 Sep 2021 18:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632189016; cv=none; d=google.com; s=arc-20160816; b=sdIgKTtvnVeYVsPWnz2Pu0MnfAAOZ1ab4ItVxhmZLf+yeauBpKU45xFDFRazYZQMiu UdWnD+BIU//lJtbYmUucUkh8m9x4Kra8S3zqeCEWDyb0yzgVxO8vszRbenV3O9Ed1nXo dCQ9s2MrQnsY/udGFf7NAIGBUC1GtDeVan4cxpSVWD5sA9CQkpAPp33CbVA5Xf3+JLSQ td1ey8kRGHIv3AMK+ogLt9XFlzMO6I20sPDUhFQudYufPAY4sf3F0+AQ0Ed2VWMb5KPK xmUY1cjqlC4CZeOO66FTqdQB6FUW8p3EQ4jX+KFOrTuXZddz3dZ7vI/ikKl3Fr3qLroP lnzw== 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=Itw7ZaiF+h8I75G3v7bwtTuoOMJXVlq8egWyTeCe/hFddom9by6LS5fHFJRA3F0AgA A6OEtonN6j9RpUuWf/iWzRIhsGzeT20auIrAyNYlJFt/k6FB0Qjqnv++f0j3N6k6RvHq 4mLGo8XZ+5L55e43FKvMZeW88iWpdUGKmUbxQnjoHdOMt7QjyNMvEejIWfaaBigvQRtO Ku4dCBV4UZT5wSUTxoSWgHnD2q6YsaimntZGTLdsKeAhBJCWvfnSJYS9He1LLJt9YS+0 VR+jJjwGNclmlHkjidYB+29ncXe6fc2fRyYD7SNVlexnfQWTU4iRrYomTjjutWdMADIA bUkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RDxYwBYA; 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 b97si14760832jai.49.2021.09.20.18.50.05; Mon, 20 Sep 2021 18:50:16 -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=RDxYwBYA; 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 S1355563AbhITRzM (ORCPT + 99 others); Mon, 20 Sep 2021 13:55:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:52996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354203AbhITRtL (ORCPT ); Mon, 20 Sep 2021 13:49:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BF6A261177; Mon, 20 Sep 2021 17:11:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632157890; bh=v6+CyDVCHXj4E1pUKK8Z0p2O+fCTC4zZOPVHoRbrJqc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RDxYwBYAQPyOXRKp9Sx2GJWNpmNkt2a0OgrbLyYS57G3E4Jw/7bVvW3RUtSLKddK2 HstgpM8xn420jWEIcEDuIuBVyaGnNA9k/t7ANb8YfeE3XVfSLqNhT4I099P4rPHsc6 prHUoGTZgGwKBRu397DI5x35G9ZuYluPgDMOib7Y= 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 4.19 198/293] hvsi: dont panic on tty_register_driver failure Date: Mon, 20 Sep 2021 18:42:40 +0200 Message-Id: <20210920163940.048339709@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163933.258815435@linuxfoundation.org> References: <20210920163933.258815435@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