mtd: maps: gpio-addr-flash: add error handling for ioremap_nocache
authorZhouyang Jia <jiazhouyang09@gmail.com>
Fri, 22 Jun 2018 01:52:20 +0000 (09:52 +0800)
committerBoris Brezillon <boris.brezillon@bootlin.com>
Sat, 7 Jul 2018 08:48:36 +0000 (10:48 +0200)
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 <jiazhouyang09@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
drivers/mtd/maps/gpio-addr-flash.c

index 385305e..9d97236 100644 (file)
@@ -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;