The patch checks that the "mtd" parameter is accessible before
proceeding.

Signed-off-by: Dario Binacchi <dario.binac...@amarulasolutions.com>

---

 drivers/mtd/nand/raw/nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/nand.c b/drivers/mtd/nand/raw/nand.c
index eacd99c4e275..d31bb580c46a 100644
--- a/drivers/mtd/nand/raw/nand.c
+++ b/drivers/mtd/nand/raw/nand.c
@@ -52,7 +52,7 @@ int nand_mtd_to_devnum(struct mtd_info *mtd)
 /* Register an initialized NAND mtd device with the U-Boot NAND command. */
 int nand_register(int devnum, struct mtd_info *mtd)
 {
-       if (devnum >= CONFIG_SYS_MAX_NAND_DEVICE)
+       if (!mtd || devnum >= CONFIG_SYS_MAX_NAND_DEVICE)
                return -EINVAL;
 
        nand_info[devnum] = mtd;
-- 
2.42.0

Reply via email to