Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp521725pxb; Thu, 9 Sep 2021 06:21:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7+lR0yKzJ6bbpJ2d9qzLDPYRexDFGvxSJG8Qv8/ymXkuDfHvXvoIqVbD23x1I78MTo4Cj X-Received: by 2002:a92:b749:: with SMTP id c9mr2248985ilm.160.1631193708182; Thu, 09 Sep 2021 06:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631193708; cv=none; d=google.com; s=arc-20160816; b=v5iVP7dHbOIDP6yt5IlUvK0HTWGPUQzGk6d2EwjyFD9JanOxpREVYSr+tnTHPhMGle Y8/WQkARpjTFykZI3FHj+8C+vZRwZdPGJxfA0OkDum0J74rTk00dMBrrcCdypcG0ropq VrWfd5jMr1CvwUhcPl7mlp675n/QwQFu155VDstpEWJaEBWECNljUXVi6ElnmcD+ubcS 3Q88yynS2d8t/iBl5dzjzWG5yRrvjyrAOdgTGkFbOut75TUR9wIkUdT6hlni/Mj/KxfU rYi5FqE/6uw4d9h/OBJUPtO0XVQNEdZ4rKZLrQrC7WJFsbiKBO+lg/ZgMrWKW3L+FLxN qfgA== 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; bh=1rBT6633PekKehWij8leOW7kWGoszFggyp4mmMwjjCQ=; b=LPIDFTcLGcWlcKiP46BEEBYc8fLHTs7eIwyy6hVCoIK85eabGnDcrRqN4i1qzJi7FN YWganqnruzurjaxGDvf8NEn6gFDZVSrWLkWRI11Httaly+BJQl93gbLGc9R2AJyrKZRZ 8utMi5Z2tWxgGKmsGvNmhGKsKBnK08eRK3tQIyNpwa2MDgyl1GnrOldjY/uPtNW7UpqQ 05/N4fK2VHaLIyllbUUduVmF8DqlJS/6BYk91C2dRhmRarGyjJ0esnZLg81zX6WBFzkQ t5XR0veLleXrM4LU00DPh92anEKp+5VVwpPxul9FoPfCDA8F9qq6IHpAgCLvcdTuNo9F LPKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sy88GMjn; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i18si1846074jan.99.2021.09.09.06.21.30; Thu, 09 Sep 2021 06:21:48 -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=@kernel.org header.s=k20201202 header.b=sy88GMjn; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353071AbhIINUh (ORCPT + 99 others); Thu, 9 Sep 2021 09:20:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:43560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357524AbhIINBk (ORCPT ); Thu, 9 Sep 2021 09:01:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D01F63286; Thu, 9 Sep 2021 11:59:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188771; bh=r446m8pgCDqDqqBFIcnPB6QgyEjhIR50RJe63O/wUZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sy88GMjngEBiTEvWFQR5AtChyLRoyPMIeGHldpZ/nsR21AqD8Qcx16W1qyb3iLVVM adnNYxe/f5jzYUMJnkrzJp7QNr0MtDrYBpdBvgTthM6O5diSwoUcoZOIFITCYQ7Gct aLVEqAtfUjwMcUNMOPWMYVNEAx2GZbKpkdzzU0+pw+aUDW+xJvbGTECTtfzYH0UI9t M2RU5f2odkRhpDu7G5NXve6rBPlM0WfPBDVLNdpDEeP2iYzIDoU8lQhqIKCYLAlpuo CEZGlZIR+kE5dP1DsL8YgAFqhovc4xLn7R9Vhixk7GsvlDLVWKWeqPKXWqctaZBQmP aBnc1D+vRSV+A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jiri Slaby , Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org, Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.14 24/59] xtensa: ISS: don't panic in rs_init Date: Thu, 9 Sep 2021 07:58:25 -0400 Message-Id: <20210909115900.149795-24-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115900.149795-1-sashal@kernel.org> References: <20210909115900.149795-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 0140a22551c8..63d6d043af16 100644 --- a/arch/xtensa/platforms/iss/console.c +++ b/arch/xtensa/platforms/iss/console.c @@ -182,9 +182,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); @@ -204,8 +208,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