Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2560196lkm; Mon, 20 Sep 2021 18:44:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNtHLnwcQ2CcB2wpRRmy1BXU/W+qprf0B0G/WQxbfySxxjK118dtR+VvkhHi6LcQ2QgvkA X-Received: by 2002:a17:906:e097:: with SMTP id gh23mr31512054ejb.137.1632188655219; Mon, 20 Sep 2021 18:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188655; cv=none; d=google.com; s=arc-20160816; b=AC+hxGwLxOsh2vRUcj2tk/W6muqnUyCRDUgHVxL7vx4QdlZ07yseohx71z/4ElKSVV AnUGHsMdWQKVxA+/hUxWQk4iGHpAHuHdIlscOlC3GDcigbO8adLMy7nc3eGOKD51PLZ7 w4xJm2iYXis2CbIomdk/cmfsxJqg9KhguE2XxjfBoAbMBsofJz4UZQNxYyfcfK5EusbR RdABgusfwUAE04HvQMxBsVFV316jmFO/b6SX2+EGOTntd1k6cJTJm8ZhEGaGv59g8OJL 0rJgy2eP7/68XvLJUmLWINasFT/oCfSrxfAoVfkJrwCAWPjwK9YKkgQjZHscZdwR/JMq kdBg== 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=RbTovTJeVJjHbJ2/iUhSWeJAyX6Nm8J4vjaUQL9Eyxs=; b=BqEzzdCvddtVwAE1J8I6OdGKJvIrAxb1nuiBUJPkV1iBE04VgNfQkw0SHmEAza2Mdh n4VY6LNnuCKFHzSyzRbYoWtX3H4Pkoih9R953pok5ypJuOyfmsei3vXX6xZ5WYTmleAc aMb1ocr6t+7e5emUKwBYBIcKqhsqgJV1R99GOnxvqcDhNh8weqci/sA2mKDy+Oq3cp3Q ceBkBCG/F41h0oBA9wnwrGgeMOcrZiH9DO5Mh0WsecMOCZ71FIWcFJvEeBybNORvjVLv 11GX1bMLxqfy2uinXD3C8QOonQTLe0zxXfzQaXgcnP801qgBlGLxKRE0QBNKX2J4DmnN CQ+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UzSK7e7+; 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 bs11si14281768ejb.438.2021.09.20.18.43.51; Mon, 20 Sep 2021 18:44:15 -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=UzSK7e7+; 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 S245450AbhITQxo (ORCPT + 99 others); Mon, 20 Sep 2021 12:53:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:39624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237075AbhITQuT (ORCPT ); Mon, 20 Sep 2021 12:50:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A04D61205; Mon, 20 Sep 2021 16:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156532; bh=YHyLKLJMiC7h8clHrRdJl/BiyZcldiTsutvJw2V/3WY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UzSK7e7+P5hHOzn2PKYK5HsuLVkYjQqN6o2faUM7GUvpLt3/SMY5zKorHs8QACb5m 1+Ay2qQB4hjjAGpub05KxfFEJoGuMbpsuF/IxeA5VHiGPLa8PUccF2B/lx7ZM9R6wC P6RWhIiJU2ChsQGmaMiHIaDqIhWd+Pl/FsGSxGc0= 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.4 103/133] hvsi: dont panic on tty_register_driver failure Date: Mon, 20 Sep 2021 18:43:01 +0200 Message-Id: <20210920163916.000566299@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163912.603434365@linuxfoundation.org> References: <20210920163912.603434365@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 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