From patchwork Sun Jul 23 04:28:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Shurong X-Patchwork-Id: 705726 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 D55F9C001DE for ; Sun, 23 Jul 2023 04:59:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229591AbjGWE71 (ORCPT ); Sun, 23 Jul 2023 00:59:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbjGWE71 (ORCPT ); Sun, 23 Jul 2023 00:59:27 -0400 X-Greylist: delayed 1033 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 22 Jul 2023 21:59:25 PDT Received: from out203-205-221-231.mail.qq.com (out203-205-221-231.mail.qq.com [203.205.221.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EA6E10D7 for ; Sat, 22 Jul 2023 21:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1690088363; bh=Qd3OAKENIQCpMIhvJEwafrb3xdlGY1wPslvTONjFmls=; h=From:To:Cc:Subject:Date; b=AAcxRDKM9un9rXQpRWgAIe6SHWzfsliwrZL7lf+lN1+WenpsVYwm7w022+pj8sovh HyeWUEhDpLvzvsqMn0txphkpImnsJGqZx0iet+i/MQfA3K+zKaq5hllW2OmDr635Kz VTjeLGDsmD+bgr1nG4WQ4z1f5Yi9/DgSeiKdMbOM= Received: from localhost.ust.hk ([175.159.123.184]) by newxmesmtplogicsvrszc2-1.qq.com (NewEsmtp) with SMTP id 730804DB; Sun, 23 Jul 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S0wdqugNC X-QQ-XMRINFO: NS+P29fieYNw95Bth2bWPxk= From: Zhang Shurong To: patrice.chotard@foss.st.com Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org, linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Zhang Shurong Subject: [PATCH] serial: st-asc: Fix to check return value of platform_get_irq() in asc_init_port() Date: Sun, 23 Jul 2023 12:28:47 +0800 X-OQ-MSGID: <20230723042847.6169-1-zhang_shurong@foxmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The platform_get_irq might be failed and return a negative result. So there should have an error handling code. Fixed this by adding an error handling code. Fixes: c4b058560762 ("serial:st-asc: Add ST ASC driver.") Signed-off-by: Zhang Shurong --- 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 aa471c9c24d9..2f1807fa9bdb 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c @@ -688,9 +688,13 @@ static int asc_init_port(struct asc_port *ascport, port->ops = &asc_uart_ops; port->fifosize = ASC_FIFO_SIZE; port->dev = &pdev->dev; - port->irq = platform_get_irq(pdev, 0); port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ST_ASC_CONSOLE); + ret = platform_get_irq(pdev, 0); + if (ret < 0) + return ret; + port->irq = ret; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); port->membase = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(port->membase))