mtd: gpio_flash: add error handling for ioremap_nocache

Message ID 1528773302-37265-1-git-send-email-jiazhouyang09@gmail.com
State New
Delegated to: Boris Brezillon
Headers show
Series
  • mtd: gpio_flash: add error handling for ioremap_nocache
Related show

Commit Message

Zhouyang Jia June 12, 2018, 3:15 a.m.
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>
---
 drivers/mtd/maps/gpio-addr-flash.c | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c
index 385305e..7fbba02 100644
--- a/drivers/mtd/maps/gpio-addr-flash.c
+++ b/drivers/mtd/maps/gpio-addr-flash.c
@@ -242,6 +242,9 @@  static int gpio_flash_probe(struct platform_device *pdev)
 	state->map.phys       = NO_XIP;
 	state->map.map_priv_1 = (unsigned long)state;
 
+	if (!state->map.virt)
+		return -ENOMEM;
+
 	platform_set_drvdata(pdev, state);
 
 	i = 0;