Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1562219pxb; Thu, 16 Sep 2021 09:57:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+DNKUSRWZ9vWa2a5AP2yr2TijBzv7FToA/tMNrbrgdiBfYoxHllzjNwqKugTukMVluHEr X-Received: by 2002:a17:906:3fc1:: with SMTP id k1mr7553599ejj.44.1631811471100; Thu, 16 Sep 2021 09:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631811471; cv=none; d=google.com; s=arc-20160816; b=TF2UthhxlNVz898jW3YH+eHVm+1tVhy1RexpD02SsJ/n8n2zytIZghT2Qw1Mp7pg16 OCy6r6jsnUtmXZpwKuJN3HJtOQvzzyZ0B/60GvPpRQAO3ZeWyGV7RK/UV5njXWl0XbI+ MoybvTrX4FNiCJsroy1u1B8UDP0QYjFVVUFkwHNmnh4ZNdtwv6XVO5GHB85AhAIdQAAJ DszlAcivBvxK/7N2P0ndhGQL5+g9DIPUU19qTmxPPxQxNVYuOsR1x+jr9z2YQ+YMyfSK Wnt09q+CTO1BlIpH1+gWzC4dQ2p0lSqB1iezTqu1KzZUI3aet5mEjbETRZcyJ++yQCqT 4zpw== 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=q351Udm4kB8rocltjF5oTlklFa9fVFWT7nb9/n2Q4Mg=; b=Ulp3FlZglpuaSNbwLxf3stWDjTnKkb7ERjpxVCgjpg90SJG2mpLqY4asL0LOt49Gx8 TIMVcTGurapMcMxt3XfuUkuh81Z8NYK+QwQbLLqtKJgc+9DRaDw4MKCi8TV96YAAAYDv hIHX81edDJioO2nfg+NIXVhw1VY4IWkEpchsYJm84ChAZyjVp8JHa9WLtbl0oML6OFUF W9Xq5s2MrNpDrhTSZe7Id/Ia0BqpwoGm+TaOECr3g2EaNR0yBl38mTarOsPKWc+wVvPJ tOsrQn8L+5P6Y5bigvJoO8503i+CsQlnVu6vccEqzfPNpWIqNbVWxkCQq2VmS9ruG6S0 qr2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d+CHwulc; 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 e3si3592177edc.457.2021.09.16.09.57.25; Thu, 16 Sep 2021 09:57:51 -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=d+CHwulc; 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 S1344052AbhIPQyG (ORCPT + 99 others); Thu, 16 Sep 2021 12:54:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:59202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344441AbhIPQqF (ORCPT ); Thu, 16 Sep 2021 12:46:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B2D7D61A61; Thu, 16 Sep 2021 16:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809577; bh=J7X6hQRAnpYD/YTkmdguiazpwXgrjhGuAbhrL0O6ZIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d+CHwulc1b9mwjjpb6Zl2UaFcFpj8+npxYBycmc6Gi3OcZCqMZ4P/nlnsgfgT0nEc fQ1qKqTls+CBqworCSrO6IRyLlWlcbKxMyY6MX67L7Tcpvh7HxMt1wDxOwqQ3ApUTG ukWEJiKFYHR/OfydNou+0tsykR7qoYxNywt1rfhc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org, Jiri Slaby , Sasha Levin Subject: [PATCH 5.13 204/380] xtensa: ISS: dont panic in rs_init Date: Thu, 16 Sep 2021 17:59:21 +0200 Message-Id: <20210916155811.009637789@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@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 23411c720052ad860b3e579ee4873511e367130a ] While alloc_tty_driver failure in rs_init would mean we have much bigger problem, there is no reason to panic when tty_register_driver fails there. It can fail for various reasons. So handle the failure gracefully. Actually handle them both while at it. This will make at least the console functional as it was enabled earlier by console_initcall in iss_console_init. Instead of shooting down the whole system. We move tty_port_init() after alloc_tty_driver(), so that we don't need to destroy the port in case the latter function fails. Cc: Chris Zankel Cc: Max Filippov Cc: linux-xtensa@linux-xtensa.org Acked-by: Max Filippov Signed-off-by: Jiri Slaby Link: https://lore.kernel.org/r/20210723074317.32690-2-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- arch/xtensa/platforms/iss/console.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c index a3dda25a4e45..eed02cf3d6b0 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -143,9 +143,13 @@ static const struct tty_operations serial_ops = { static int __init rs_init(void) { - tty_port_init(&serial_port); + int ret; serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES); + if (!serial_driver) + return -ENOMEM; + + tty_port_init(&serial_port); /* Initialize the tty_driver structure */ @@ -163,8 +167,15 @@ static int __init rs_init(void) tty_set_operations(serial_driver, &serial_ops); tty_port_link_device(&serial_port, serial_driver, 0); - if (tty_register_driver(serial_driver)) - panic("Couldn't register serial driver\n"); + ret = tty_register_driver(serial_driver); + if (ret) { + pr_err("Couldn't register serial driver\n"); + tty_driver_kref_put(serial_driver); + tty_port_destroy(&serial_port); + + return ret; + } + return 0; } -- 2.30.2