Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1534066pxb; Thu, 16 Sep 2021 09:23:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydvLbG3lGNoOeVtw/HBxIc9mIwqxE58SvQ3y4UnCACxeCNzpwA2zsRm5suFxM/8esbzEvE X-Received: by 2002:a17:906:37d4:: with SMTP id o20mr7174049ejc.508.1631809428200; Thu, 16 Sep 2021 09:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631809428; cv=none; d=google.com; s=arc-20160816; b=SXuntZmm94D8b44sRakJ3ZosT8p225GarShHGxe+tPR127wJ7yDFGX893UJkV3FUEg g044LX+MK2HJJhHl7vzUFR3973zznL+NEdjFU+xyl7F6zcf/mYO0fZsuc+veDo+xes2E nCLYPtdiCZesKdLby5eiRJBktChc/wqSRhHmsofqm24SpFId588y96cFKC2wTtJydAnO 0clvRw9ehuqR2YC+9IRIrSJek2SOKiu8ax5LZHE06/4Jf0aEi3QxocODZQKgADzPEpQb inE0HqkZMpaWlw2LiPVEt/3Hm97NOqW7pb/4nTMpYThse3ZrbLY3GfsINFtNdwbcZf5x zjqA== 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=q3KFqziJ4FND6ijjHZtTNQMkoDCrlLijN6NyB8avHq5bIjkorf150uN4hwtIRxGl5j b3pyeB/glD7Z3RyeGzpGnPENipBMIJXAqilIA0nXa2qudbJCgeqmj6K2BIo3J0o37064 WWxjmFzwsPs4LmmpB31QvoB2znD6A95qBAL6K5A3BOnGdbm/TrQocyi1JR8vcfSgEw64 SrtvlXrimf4gZRqaLewqpN/VKgo81H/FfidE7J0PoZhPmVkA2cxzb3wapGM+o7GhccyY tCu3BJ9tdSqgfyF2YjioLz3vcNMfAHiCtNF4hOxCG1g2zjEgw9G2++GIeTUoQAkUBWNc lcDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AVpe0Ipk; 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 di3si3884494ejc.490.2021.09.16.09.23.19; Thu, 16 Sep 2021 09:23:48 -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=AVpe0Ipk; 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 S241295AbhIPQWi (ORCPT + 99 others); Thu, 16 Sep 2021 12:22:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:55014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240774AbhIPQO1 (ORCPT ); Thu, 16 Sep 2021 12:14:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CDCB861251; Thu, 16 Sep 2021 16:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808628; bh=HJZadhkc3lcjE7AapxAuKY6kRDDcL5N6KsyajWYJPs4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AVpe0Ipk99EfZZiChYmiykqT/haUIG2Oux5Wp033Ll6S8q7Kjgd4PYrFoCKpT/7NC +NJOin62nEXYmm1rkSHeeys8mrIQyftfGtLXLRN0Es8hXg1HRKq35hkvTbsnmHhair zbQcL22MbX/hKgjfreYQ8lBTOW7bVG03C+DMIqHU= 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.10 163/306] hvsi: dont panic on tty_register_driver failure Date: Thu, 16 Sep 2021 17:58:28 +0200 Message-Id: <20210916155759.643929193@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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