Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2319369pxb; Mon, 20 Sep 2021 18:42:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGSOt9XgvouhrzFBUJJafOL9fQ1Hgz8PJtyXr04N5SDYm3BMgmDUpxYdzO50SrN9UMbrAT X-Received: by 2002:a05:6e02:1a0f:: with SMTP id s15mr9073166ild.259.1632188545086; Mon, 20 Sep 2021 18:42:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188545; cv=none; d=google.com; s=arc-20160816; b=0y05I7uEIwAbzp61AcHmkUswVVYQkMRL1Avc9ylL1Xsnk+eD8H3VFGVnooQhrDvZX6 vzCRid0LdXjtPfFnY6VFiGOVLZr0t2xsoahX/oLXSzJPqf1KMUeDBN/7Bw1s11JHPvpf Lb02d0mfn1jiNbiWkE2rBbvheugzEpCG0WCsjPKDWyrpPSuyk/K8XZ40tYU0XFdIoIge dyyzhgsrD1cpjxgfsnVeMKxZrFe2uHk6pDWxPixIwEMKyymYhNp2jUGYpH99L0BO6L1S V6EWsQMQ2eZtzRL5FhYi/yijTab0yb3tjq+76idQYq8NC7uVHu4ZLR6ONvNBHgSv5V2Y Ix2A== 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=etYpoGfMtrPlmCCUyHhIoJGNTtu/WXsBwu+UUqy7yNE=; b=mcND6SQqngjGl6Kr8iKA1VgszlL15srM8WUYcqlgSb3ckQLuvOuEDdReBgfFJZ/zY4 G1jr4PLwCYhg2kdrt29+HcpKGzCzuxzcDrn2P2/JadSWp8I+dd/tZCmUEg248EHe7WDK 1VLLGnk1PcDcQNt9n/EDq0OZKNu3eKWbeQ5Gqo0n3FsRo9hjP3RxeQ+rScfTbuQfrsi4 erdDSIJOXEc1A6oXbtPJPR0pnMtWQjykmnlKgLbAwlh7PBCtMtTi7EecOX7wYTtxKmvA ldnvI7GccpBZwGabwUWKxMKXe2aKOxIrLtU5U/N7qadhRh+6zlagIKY9OI+/39hUtFLx emPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cz0PbdNr; 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 x17si14627675ilc.170.2021.09.20.18.42.13; Mon, 20 Sep 2021 18:42:25 -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=Cz0PbdNr; 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 S245439AbhITQxm (ORCPT + 99 others); Mon, 20 Sep 2021 12:53:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:39558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbhITQuS (ORCPT ); Mon, 20 Sep 2021 12:50:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 157E3611ED; Mon, 20 Sep 2021 16:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156530; bh=LzuumibSxZczbRCy/9ENplua8GtJNGJLSESXArKcQ2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cz0PbdNrc6+ZCax/41GYwCoVNea4In6mw16OaNLqCeXb/ZHND0gxnBxrRpD91VaIx Aqd1O1FLJN1BODOFqET5Rg77cGa9SUAATFgcxW3he1bh1m3qFxSeJ416RMxZdXQbvr PN+8zukVbuqdKP3RWnFKVmfb+4dGWJbVch9XyC20= 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 4.4 102/133] xtensa: ISS: dont panic in rs_init Date: Mon, 20 Sep 2021 18:43:00 +0200 Message-Id: <20210920163915.968208955@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 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 92d785fefb6d..5d264ae517f5 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -186,9 +186,13 @@ static const struct tty_operations serial_ops = { 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); printk ("%s %s\n", serial_name, serial_version); @@ -208,8 +212,15 @@ 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