Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1927980pxb; Thu, 16 Sep 2021 20:34:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNv9L0JmCOfX1EZ7e2a24TV3z3h2XdlZ2g62ivlmOmIsmmBD0dMCmn+LFgOc7+FC2/8ige X-Received: by 2002:a17:906:30d0:: with SMTP id b16mr9994393ejb.495.1631849679456; Thu, 16 Sep 2021 20:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631849679; cv=none; d=google.com; s=arc-20160816; b=MdE8YiASPdoTMxSPgKSDobLlJGQa4f9/l9qJA6lnEBeC3Va3nU1YqbXZllfbNR72JQ yPIFHg75J9kW76TSSeQQNFIJEv30TCuuwYq91q+Q+WQHVeC2c5gUeBU6Qp307W2Z3cvC MNZm9uOBaU13U3M91511IQ5TNdjcmGTFzlWE+LrNkKN+u8mr4bKbPbotJ9VlxpGAfzlP M0J452pUfzJAI32p80zia2ZiNKeEdAnZ5uESeen4273gply4Wfy4uEb6xOgKUm6vGp+r towruPFQAMeCEoFEeA0h1KFjEUuk4LtGUIfkDYz9Oc9XKIqNPvEzU3w5VWMaGrH/4Kcx fynA== 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=AIyfifibZJTs2Mi8MgcfGdSmbW38JC7EuUuYzro/auQ=; b=05+buOw14DmWda1bTxooYi58tZAOR6CZVSWoAtcljKYXIpYmW7sTW23Xo+LoS1CqZq e8op6Dbl0J1BJGoAiiAheFkzhFzzVgl+oZdZubkWV8ZhgSl0rrqenajQPo4GefBfkKx5 DmnI8AGsW8+WNTp1mvVtR+4Xsyu0yTbgQSLstjsaqpOGfy9hLS0yjSyDfFgRc2U8P+2n tWJFXX4sfxz5l0FJUsCstqupndeYT85K5CI8i27EkTkcR5P05GYafmpdcT4niibyjYff OKIvftL5BJETIjZjxxVFhZUOUjt/YFe4dIlKszgcDz51Ubei9lLwHBpq2IHXPUWwRyI+ AvPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tmp88+vU; 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 z15si6417613ejr.28.2021.09.16.20.34.14; Thu, 16 Sep 2021 20:34:39 -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=tmp88+vU; 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 S1346699AbhIPRgK (ORCPT + 99 others); Thu, 16 Sep 2021 13:36:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:47084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352260AbhIPR0z (ORCPT ); Thu, 16 Sep 2021 13:26:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0E3BF61A59; Thu, 16 Sep 2021 16:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810710; bh=feZctuRMHO3yQPCszFkVhvDJ3n8/xXu4EUqmJR3PgeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tmp88+vU087f0xImbXfZBDc9fd+ohPIwApiwRyMMoWphTrAHfH7h7k4T7ERwGQJ+i 7lyXBA4nnTmPaDs98gQ4DwKkh1RX891/TeKJKb2AQwnHTSD3dm+S4NRNwCLA4gYua1 YtV/yfpX5Zf5YmsNUQhlO635JmqVgxklvFbZQMOc= 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.14 232/432] hvsi: dont panic on tty_register_driver failure Date: Thu, 16 Sep 2021 17:59:41 +0200 Message-Id: <20210916155818.713126340@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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 bfc15279d5bc..f0bc8e780051 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