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 <[email protected]>
---
Cc: Rouven Czerwinski <[email protected]>
---
 drivers/mtd/nor/cfi_flash.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/nor/cfi_flash.c b/drivers/mtd/nor/cfi_flash.c
index 225b03ec3d23..ba0bd1b4ebdd 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",
-- 
2.30.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to