From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF2C6C4320E for ; Fri, 23 Jul 2021 07:43:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC26C60E91 for ; Fri, 23 Jul 2021 07:43:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233833AbhGWHCu (ORCPT ); Fri, 23 Jul 2021 03:02:50 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:59002 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229816AbhGWHCp (ORCPT ); Fri, 23 Jul 2021 03:02:45 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 1533C1FF60; Fri, 23 Jul 2021 07:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1627026198; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TLnj3fE5KMFGqX2qLEAXuWHCdRAGkYqk7WbrMRV0+KM=; b=Bum/vlVR9494nes/U3WkOiM5/3Ggzn5CO/EuMo9lsnBNMCGjk2yKiU2EneK86IITkBWkmN zZDdCBhenEQ+Yw1ihipSq5eItHLtZaJob6Kv5pestzEdhOqYXur9Dwhn8cG0XzbhNgyjxP 3YxD5QXQE64uXsnqiqGGZs4bmcka00A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1627026198; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TLnj3fE5KMFGqX2qLEAXuWHCdRAGkYqk7WbrMRV0+KM=; b=hKgr2SyHWWlEh+mEgJ+0gBH5Ey+RHTzyswUBfi0ezXsNqWrKW3WUUE5CYJ6bXGmK8gkhMO eFu6zSSHY1pD07Aw== Received: from localhost.localdomain (unknown [10.100.201.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id D866DA3B95; Fri, 23 Jul 2021 07:43:17 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby , Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org Subject: [PATCH 1/8] xtensa: ISS: don't panic in rs_init Date: Fri, 23 Jul 2021 09:43:10 +0200 Message-Id: <20210723074317.32690-2-jslaby@suse.cz> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210723074317.32690-1-jslaby@suse.cz> References: <20210723074317.32690-1-jslaby@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Jiri Slaby Cc: Chris Zankel Cc: Max Filippov Cc: linux-xtensa@linux-xtensa.org --- 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 21184488c277..0108504dfb45 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -136,9 +136,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 */ @@ -156,8 +160,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.32.0