diff options
author | Ahmad Fatoum <ahmad@a3f.at> | 2021-02-28 20:07:05 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-03-01 16:57:11 +0100 |
commit | 767edcc58757b4f52175a1fca5fa7d1818cdf142 (patch) | |
tree | da0fae54d595acb50ed14a0a8f82788dc38c0226 /drivers | |
parent | be077c7512440d1e52f96210a6855f171579f6f5 (diff) | |
download | barebox-767edcc58757b4f52175a1fca5fa7d1818cdf142.tar.gz barebox-767edcc58757b4f52175a1fca5fa7d1818cdf142.tar.xz |
mtd: cfi-flash: fail gracefully instead of crashing on NULL page
Until this is fixed, add a comment and have the driver return with an
error instead of crashing on null pointer dereference if it's mapped to
zero.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/nor/cfi_flash.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c index 225b03ec3d..ba0bd1b4eb 100644 --- a/drivers/mtd/nor/cfi_flash.c +++ b/drivers/mtd/nor/cfi_flash.c @@ -969,6 +969,10 @@ static int cfi_probe_one(struct flash_info *info, int num) return PTR_ERR(iores); info->base = IOMEM(iores->start); + /* TODO: either remap memory region or disable NULL pointer page */ + if (IS_ENABLED(CONFIG_MMU) && iores->start == 0) + return -EPERM; + ret = flash_detect_size(info); if (ret) { dev_warn(info->dev, "## Unknown FLASH on Bank at 0x%p - Size = 0x%08lx = %ld MB\n", |