瀏覽代碼

mtd: maps: gpio-addr-flash: add error handling for ioremap_nocache

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>
Zhouyang Jia 7 年之前
父節點
當前提交
c31106b7af
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      drivers/mtd/maps/gpio-addr-flash.c

+ 3 - 0
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;