Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp517186pxb; Thu, 9 Sep 2021 06:17:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7LCFEMyTpLTJm5By36MaPLU6T517Y0e8JG2OPpCxoMdCRRH58SnEMNWqp/QmMB60pYgHU X-Received: by 2002:a2e:2417:: with SMTP id k23mr2172411ljk.256.1631193420835; Thu, 09 Sep 2021 06:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631193420; cv=none; d=google.com; s=arc-20160816; b=tWOs7IqR++sFInhRAwkx5baUtUlpWqlP2dw3m7WJgMyiE99cvEdfcrIznfco/7ebjR sdQWf9piA6EkIUGsVDl7FoOCnngZ+SN/z9v92iqijAhB9B9F6ZgD9+be1avL8Dyqt4eX juT1tAP8TJMNW5WqpnPkantFX01gxh84QYnWz2g+xMWORRXLJ0N0OcNtFuEZN8NeYvP5 zrpHaNqn5jEBizNbSK+4XcQPAgL92a6yVpGdBCb4KA1eJdIMP0d//e+mhG1y7drFmoI0 ynXi9s2rXGuqWI9SiuWpPwVFzOTilItcFZSgwsJlV+xKYmsV5zjKCYDi/xoICwsZu2eL goFw== 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=hM9yXsjHcxGtyZfFMnSis1aIPMfsQlmidtirGGC5RF8=; b=rOURgAMy/CfTPaBd5bwO5/F8eMtE/ALsEm6KMSYVEZCE/dlTItGEYKfgSKxp7afhc+ DmP0sLKHgkrXPrPJgYWupICm1v5Xxa04/HugccsfJ7v7mDSS4gO58PCQswFSIuL0VUHb iTqQ9zOFPpDwKhAlJfNJGrG8TJM1CUO2O6wvbLcivp3rqedJ3K1uJV1L46xBc1NUvkAt HiNE4MrQw2BA5YqI2WCVSzKoRttmVAGlRVYwd9f4P25dQa3Dy0FCMlyqnfIzq4e1DFNc bEbO9QdST4FY9zlx1+zgumSTVVnMtd/kNMu3miqVURjv/aSD5xwrTWMM30DNEZXk0Miy Z/Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eJDYDaA6; 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 kx11si1664774ejc.554.2021.09.09.06.16.32; Thu, 09 Sep 2021 06:17:00 -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=eJDYDaA6; 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 S1354699AbhIINNR (ORCPT + 99 others); Thu, 9 Sep 2021 09:13:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:43552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357527AbhIINBk (ORCPT ); Thu, 9 Sep 2021 09:01:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B59DB6328A; Thu, 9 Sep 2021 11:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188772; bh=PPM/jXHmTtR/M9ZsSaVnvwKdTCr9Kp3n0mIOVTS9KFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eJDYDaA6KwzEuA32SxPN5r1+U5b5e09urfX2K8DX4NmqZS2xQkeAh2BCWErJ3k9uc MxNggo/cL2rvsYgmGch8aU5moBmqobgy5gr1hD+YIAA8Lwq1pY1lo7VtnlVlLgtp0r nGUJbFQ5+GDT7ozUug9/Y3SOT7o6lUWz/iS1TuGxnn6n+SjM5jmLNFG2lmZBUY44Ai 25fESPbzVt0TOLt1M/25W+01YtbmKAlPfkSlYgcb/3UBXpvWh80lGwb3PRdWTAkl+G ECZF612lhalo19pCccPNM1J4smBpuQd5znTJlr2gczWe9OBXTqmYPBhHTftkLhFyD9 cViNhfzdeypXQ== 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 4.14 25/59] hvsi: don't panic on tty_register_driver failure Date: Thu, 9 Sep 2021 07:58:26 -0400 Message-Id: <20210909115900.149795-25-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115900.149795-1-sashal@kernel.org> References: <20210909115900.149795-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 2e578d6433af..7d7fdfc578a9 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