Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp448684pxb; Thu, 9 Sep 2021 04:50:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCcskl+MTJ/8tT98hI+e0Fz9QwgYJWzTDZp9IwVABQBFArFy5iX7vgO8Jdu9KNMFnwUsJb X-Received: by 2002:a05:6402:27cd:: with SMTP id c13mr2729419ede.266.1631188247510; Thu, 09 Sep 2021 04:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188247; cv=none; d=google.com; s=arc-20160816; b=r9DUwTiuFy40HgTLzDL6SP6/CySny8Q72sLJkS5/biHx0Wqfnk9k+YVbL/2eJMq5H8 QRvjWufdoIHvBl42fUDtE8EDrAEDVb4dveN6PdLAQLhsSaOv00BjYHhpN8Qba7Pbbv7r TpxL8Qcbn+9kpGUDE02KdSzhC07eX10A+EuW/5t9wLgiAQMfVJDAa0aymkn81trfu1UN 0m/srwtsG6f8DCzbUKD2nnzkrw8941bNmPNLIgpV+g14BfiNf/DVsZkG03l7sLoDUJE6 YiWXzcpyZgJRSsU0laTXObk7cZtKJ0KS2vaevfGxWcSXnSAmBfBZ33FDGXG5M4Nds91Q wUoQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AIyfifibZJTs2Mi8MgcfGdSmbW38JC7EuUuYzro/auQ=; b=WeWLLdLkIb+QHSut1Pg4HwAv/z1ATKeED1po53EBxQfMCC0+GyVy7wFYjmqr6ALrkt CY2eAhOCJBZLp83ATcGiRb/NxyLtTsn2ed3bAp8j/jWNI/bgMJq+He8I4A8l1RFZioKj ErSK3LEukmJuiQH1wDIS8/KZ2ldbs9rgUl064NNlmYULCycmquLdFs409pOxK0W1glhw lWeXIztamk0J7TdqqXKtCgD87Sku+XBxiJypNsEx7LJQ0ZLH0k1gTJO5nyGjBUPQbf25 g3s4xNvmc8nHwXW0UzunKEatmTeV3SugUZsLNbp2xYNwzzUnR+zrEPatYYOQgTFx7YkP PwLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z22Ueqz1; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp12si1780689ejc.300.2021.09.09.04.50.21; Thu, 09 Sep 2021 04:50:47 -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=@kernel.org header.s=k20201202 header.b=Z22Ueqz1; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236735AbhIILsE (ORCPT + 99 others); Thu, 9 Sep 2021 07:48:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:45714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239423AbhIILps (ORCPT ); Thu, 9 Sep 2021 07:45:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ECBE5611AF; Thu, 9 Sep 2021 11:42:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187768; bh=feZctuRMHO3yQPCszFkVhvDJ3n8/xXu4EUqmJR3PgeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z22Ueqz1Ret0oTLDAegPT9G32l5jRc67FaavZP6DrwRSQuF0uR3dxwAx1IkTW+YqM iRRhf6KKglwcrpXCaitvcMqxxZdOemlcvGzZEgnJWo4qW1OIn3O395MD4qw5KarA1F mW8v4NDjZ7CBadCPJqaDNXOD59iOFTzw8nVXqYxKQNXiczm8NtZ6FJ1tHIBhZW6DeH 6CmfgT39p/diGXgLFlnjjyTm21/HaryYP/ku8mAPZSlaqG8RnS7r04gKkmYuJxaNMP OHV2wS2Lf+XvqCi10L6vJHYV82kKXhS7yoV7gCb/J/3BxDSAvEOUEaoe+wE5Gsg5uE FJFRIBKEP+Brw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jiri Slaby , linuxppc-dev@lists.ozlabs.org, Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 5.14 080/252] hvsi: don't panic on tty_register_driver failure Date: Thu, 9 Sep 2021 07:38:14 -0400 Message-Id: <20210909114106.141462-80-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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