Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1700493pxb; Thu, 16 Sep 2021 13:20:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIflm3xS8kJS2Sh1/31moK3AFm6wbxz5njFrnMbO7/Jjlb+zv4RICNvl0KfXTndJAXlExM X-Received: by 2002:a05:6402:886:: with SMTP id e6mr8430872edy.41.1631823633988; Thu, 16 Sep 2021 13:20:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631823633; cv=none; d=google.com; s=arc-20160816; b=TvmseUdVvZ6j/CbTNBtg+6JTo4os/VLW5u890zB8lsQVjSW6uYGBRba7tbXX4TI8lr tkioXLmlYuuaNl0mKUKlcVwe2k8zkAR5flXBVA16DZpGjrDF40C5ZLs7C3diY8MhqmCS uH4HRfixChAvHeCk3jvkHHwOcmUuF6B/shsXlxcoxoLxvx6PffSA5fJQzeI6VW0k+0pB wWBV/lHShfUw6xhZ5wAwJjuBi5iDoWMckXDPLcSMS1fXlK+NFwZJThjGRYCtpqJL7vPU JWzhHsPSWsY7jDBPC2rbxUWJ2tDHVI7R00/TH84w/+jeRrIfPko3oXbTijD9sOiXff6O nghQ== 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=5si5wqIDxUewRj5cPx1T/sGxphPRF7DZGYQhR/tfPas=; b=oSSpUPaNoN5lykOZ+M906wJPCbvNWz9M3Fm5wdVHKiWGkCKfSaVpWw6mreZ/d6DTe8 /2+up5usZbGXKFNR26hqkELCnnFgGLeCZ/YieP3e7b/+TOtE4DtsDaMmugosKDz0LqsT dLXh0tQtUkW0KE1nIRhsL5R5CCsFmj5nllhSGeI3rhHL5CAcyD5kCZvdt690wxdOHolU i/NhDLC9UKjIZnxgNcA7MnZK8FqMqf5if4+KcGMk6Q7vhGv+U6wRVes0p36MoJwzr6K/ yqurz/B1OB2j+BnNNdKH0MXWBnH+VE3+fdna1+VpkIgtnEGWRk65rtH6jzIhWv3QqZNa NSyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nycLAwBF; 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 m17si4465945edj.627.2021.09.16.13.20.10; Thu, 16 Sep 2021 13:20:33 -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=nycLAwBF; 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 S241259AbhIPQWl (ORCPT + 99 others); Thu, 16 Sep 2021 12:22:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:55010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240761AbhIPQO0 (ORCPT ); Thu, 16 Sep 2021 12:14:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 14EE76120F; Thu, 16 Sep 2021 16:10:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808625; bh=76eGioPcotaQYkVwzDjxwSd4GCkgGhVHJKyA11UTrHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nycLAwBFrGVDDvXPOxuSjg0j10bVlc0UynwR8m3dzlsnRvttbosRYU895jyLZtuNI swB3zQa/C5sJPItzrGknyu1/Ig9S5vALoQER8DClKv8JFzdt5VTsley/41a3DGmpYb 9uYfhaQjoyWZJ8QUXT0RSKtSTFXMz5gGk3cVDBkc= 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.10 162/306] xtensa: ISS: dont panic in rs_init Date: Thu, 16 Sep 2021 17:58:27 +0200 Message-Id: <20210916155759.603751542@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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 af81a62faba6..e7faea3d73d3 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -168,9 +168,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); pr_info("%s %s\n", serial_name, serial_version); @@ -190,8 +194,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