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: 13373462 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51DF3C83F2C for ; Mon, 4 Sep 2023 03:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=NjgvUe/vkbA9UVmBm/VEDDpmeydCsTAQqWbKTNDTsjk=; b=1wACCDd2jv9qxh nBV7rXAUBM51A2yskgIlJgQ4j0eNUFPejWyZD4n7mDx7qsUdhfIicKntLxz5aexTWA/JRGC1N6AaH BAu5ZQeMvzVK5vnhgLu7ntmWxGA1kzCAGZ1Ndxx3xjzru/vu3y7XjuS/OVZaZka4rZjCMI8G99xEX gjm/W2wt47yjL0sgElhvk+u8hzEzGl6W75/0CERaEHG+oK5yzwhawWXlIrX8mfem4EyueI3RxU/kq pDGN+kf8YfJTi1IKOb2zUoZzwy6WqNHeGN+KMU5EsTRiru3K99AkuQuKa1pijqY07e9D64qSR7I6Y nzor3MuSVlOCdHKBCtGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qd0Sa-003CxC-1H; Mon, 04 Sep 2023 03:41:08 +0000 Received: from smtp81.cstnet.cn ([159.226.251.81] helo=cstnet.cn) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qd0SU-003Cw5-0N for linux-arm-kernel@lists.infradead.org; Mon, 04 Sep 2023 03:41:06 +0000 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: rQCowABnbqK9UfVk2+twCg--.59946S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Xw4UtryUXr1xuFW7ZF4rAFb_yoWfZFX_C3 Wku3yIvr409rs0kw1Sqry5urWftryqvF4kWF1vv34akr98CayDWFWjvrnFkr47uw43WF15 tr47KryfAw1qqjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbcxFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_ Gr1UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr 1j6rxdM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkIecxEwVAFwVW8 GwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r 1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij 64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr 0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF 0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUjQBMtUUUUU== X-Originating-IP: [124.16.138.129] X-CM-SenderInfo: xqlfxv3q6l2u1dvotugofq/ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230903_204102_556136_E97A139D X-CRM114-Status: UNSURE ( 9.37 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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);