Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1152351pxv; Fri, 23 Jul 2021 00:44:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJy0H+SAvdH9nBEJQxPhE4pN4mDP0UHDM/jv2BLsmDjLKmgNM0H9vv+lEE2FEt6qNFdbcb X-Received: by 2002:a02:cce6:: with SMTP id l6mr3071914jaq.114.1627026259878; Fri, 23 Jul 2021 00:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627026259; cv=none; d=google.com; s=arc-20160816; b=hi0ty5kK7joBF9BvDKiHZ+7IJ0gaYhh8wGFU6BAERxgi/lf7J1XZiKzV5PIFYR0LSC W9bNBx0NBy9x0w/4Jj4IOkmUKi3CFfOvMn44PIAQuLVeJG9lq2Nf4WIv5+wPQawj5uFG 21INGqYAvywSjuAdi7jTj8QZdc9voEx0epDCV6tzdJJssEgrA8SqQ1AcFD04nKpAQqtW G0b9qIfE+iYPTEoulnvXtcM5GlsglsWC45D/NezdbuXbET1iUefr8kz6Q2RNjaiQHTow UN3VoJVq+p0H7ltZIgTAtYnXvlAupfP/s1oAqrwhiANEvK9gP1m/TINR5UuMs3lItyLw nVYA== 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:dkim-signature; bh=TLnj3fE5KMFGqX2qLEAXuWHCdRAGkYqk7WbrMRV0+KM=; b=03iyKwNuu3fkvjJi07Bs+vfYcjwfbm8UZUFv0nX7XGFPxd0gSousTPvdwaG1j4y7ut nHb8gQEs1x7Tcdz3T7coGoVFUaqAxnby+rtwKpwupCd+Ae33rkEkJQpkCUUsRW7z3J+z dMuZwaoEG/ZWlQkqmeOtN3Gt/hkNEoxZHeq7a24jfj5wn557c8huAgq13wzr8ae0rKiX JQL1YPRcu26uKfuItnXAYqW446WleyiamhOx+bkZURyN74yYLYE7pqOYrdSmDRWX8k02 ymg3K3ad0KPV60zJUVFZ8WgaIR+ssnhRdA8kGJ4FZ0Lru6a8o/PPAe4nRTo0ssgkowh0 JedQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="Bum/vlVR"; dkim=neutral (no key) header.i=@suse.cz; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s8si34405880ilu.146.2021.07.23.00.44.08; Fri, 23 Jul 2021 00:44:19 -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=@suse.cz header.s=susede2_rsa header.b="Bum/vlVR"; dkim=neutral (no key) header.i=@suse.cz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233934AbhGWHCt (ORCPT + 99 others); Fri, 23 Jul 2021 03:02:49 -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