From 6b3d175928417f55537fe271df983f7ed52915f3 Mon Sep 17 00:00:00 2001 From: Dario Binacchi Date: Thu, 2 Nov 2023 12:27:33 +0100 Subject: [PATCH] mtd: nand: complete nand_register() arguments check The patch checks that the "mtd" parameter is accessible before proceeding. Signed-off-by: Dario Binacchi Reviewed-by: Michael Trimarchi Link: https://lore.kernel.org/all/20231102112743.57420-1-dario.binacchi@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 4c18861aa2..c1a0ebe648 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.39.5