mtd: nand: complete nand_register() arguments check

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

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Link: https://lore.kernel.org/all/20231102112743.57420-1-dario.binacchi@amarulasolutions.com
diff --git a/drivers/mtd/nand/raw/nand.c b/drivers/mtd/nand/raw/nand.c
index 4c18861..c1a0ebe 100644
--- a/drivers/mtd/nand/raw/nand.c
+++ b/drivers/mtd/nand/raw/nand.c
@@ -52,7 +52,7 @@
 /* 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;