From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fWBFl-0006fD-3g for linux-mtd@lists.infradead.org; Fri, 22 Jun 2018 01:52:46 +0000 Received: by mail-pg0-x244.google.com with SMTP id m5-v6so2237547pgd.3 for ; Thu, 21 Jun 2018 18:52:33 -0700 (PDT) From: Zhouyang Jia To: Cc: Zhouyang Jia , David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] mtd: gpio_flash: add error handling for ioremap_nocache Date: Fri, 22 Jun 2018 09:52:20 +0800 Message-Id: <1529632343-70907-1-git-send-email-jiazhouyang09@gmail.com> In-Reply-To: <1528773302-37265-1-git-send-email-jiazhouyang09@gmail.com> References: <1528773302-37265-1-git-send-email-jiazhouyang09@gmail.com> List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , When ioremap_nocache fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling ioremap_nocache. Signed-off-by: Zhouyang Jia --- v1->v2: - Move the test just after the ioremap_nocache() call. --- drivers/mtd/maps/gpio-addr-flash.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c index 385305e..9d97236 100644 --- a/drivers/mtd/maps/gpio-addr-flash.c +++ b/drivers/mtd/maps/gpio-addr-flash.c @@ -239,6 +239,9 @@ static int gpio_flash_probe(struct platform_device *pdev) state->map.bankwidth = pdata->width; state->map.size = state->win_size * (1 << state->gpio_count); state->map.virt = ioremap_nocache(memory->start, state->map.size); + if (!state->map.virt) + return -ENOMEM; + state->map.phys = NO_XIP; state->map.map_priv_1 = (unsigned long)state; -- 2.7.4