From patchwork Mon Sep 4 03:40:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Ni X-Patchwork-Id: 720343 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 587F9C83F2C for ; Mon, 4 Sep 2023 03:47:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238097AbjIDDr7 (ORCPT ); Sun, 3 Sep 2023 23:47:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234314AbjIDDr6 (ORCPT ); Sun, 3 Sep 2023 23:47:58 -0400 X-Greylist: delayed 417 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 03 Sep 2023 20:47:54 PDT Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F16C9EC for ; Sun, 3 Sep 2023 20:47:54 -0700 (PDT) Received: from localhost (unknown [124.16.138.129]) by APP-03 (Coremail) with SMTP id rQCowABnbqK9UfVk2+twCg--.59946S2; Mon, 04 Sep 2023 11:40:45 +0800 (CST) From: Chen Ni To: ychuang3@nuvoton.com, schung@nuvoton.com, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Chen Ni Subject: [PATCH] tty: serial: ma35d1_serial: Add missing check for ioremap Date: Mon, 4 Sep 2023 03:40:31 +0000 Message-Id: <20230904034031.23311-1-nichen@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: rQCowABnbqK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138.129] X-CM-SenderInfo: xqlfxv3q6l2u1dvotugofq/ Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Add check for ioremap() and return the error if it fails in order to guarantee the success of ioremap(), same as in ma35d1serial_console_setup(). Fixes: 930cbf92db01 ("tty: serial: Add Nuvoton ma35d1 serial driver support") Signed-off-by: Chen Ni --- drivers/tty/serial/ma35d1_serial.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/tty/serial/ma35d1_serial.c b/drivers/tty/serial/ma35d1_serial.c index 465b1def9e11..dbfcb711e710 100644 --- a/drivers/tty/serial/ma35d1_serial.c +++ b/drivers/tty/serial/ma35d1_serial.c @@ -695,6 +695,9 @@ static int ma35d1serial_probe(struct platform_device *pdev) up->port.iobase = res_mem->start; up->port.membase = ioremap(up->port.iobase, MA35_UART_REG_SIZE); + if (!up->port.membase) + return -ENOMEM; + up->port.ops = &ma35d1serial_ops; spin_lock_init(&up->port.lock);