From patchwork Wed Oct 18 09:12:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Yang X-Patchwork-Id: 736155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 788FECDB47E for ; Wed, 18 Oct 2023 09:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229449AbjJRJOE (ORCPT ); Wed, 18 Oct 2023 05:14:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjJRJN4 (ORCPT ); Wed, 18 Oct 2023 05:13:56 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F2ACFA for ; Wed, 18 Oct 2023 02:13:53 -0700 (PDT) Received: from kwepemm000014.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S9Q5G3vzqzvQGs; Wed, 18 Oct 2023 17:09:06 +0800 (CST) Received: from huawei.com (10.67.174.78) by kwepemm000014.china.huawei.com (7.193.23.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 18 Oct 2023 17:13:50 +0800 From: Yi Yang To: , , CC: , Subject: [PATCH] serial: st-asc: Check return value of platform_get_irq() in asc_init_port() Date: Wed, 18 Oct 2023 09:12:40 +0000 Message-ID: <20231018091240.314620-1-yiyang13@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.78] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm000014.china.huawei.com (7.193.23.6) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The platform_get_irq() might be failed and return a negative result, there should be return an error code when platform_get_irq() failed. Fix it by add check return value of platform_get_irq(). Fixes: c4b058560762 ("serial:st-asc: Add ST ASC driver.") Signed-off-by: Yi Yang --- drivers/tty/serial/st-asc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c index a821f5d76a26..8321167502dc 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c @@ -683,12 +683,16 @@ static int asc_init_port(struct asc_port *ascport, struct resource *res; int ret; + ret = platform_get_irq(pdev, 0); + if (ret < 0) + return ret; + port->iotype = UPIO_MEM; port->flags = UPF_BOOT_AUTOCONF; port->ops = &asc_uart_ops; port->fifosize = ASC_FIFO_SIZE; port->dev = &pdev->dev; - port->irq = platform_get_irq(pdev, 0); + port->irq = ret; port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ST_ASC_CONSOLE); port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res);