From: Dario Binacchi Date: Thu, 2 Nov 2023 11:27:33 +0000 (+0100) Subject: mtd: nand: complete nand_register() arguments check X-Git-Url: http://git.dujemihanovic.xyz/%22/img/sics.gif/%22/static/git-favicon.png?a=commitdiff_plain;h=6b3d175928417f55537fe271df983f7ed52915f3;p=u-boot.git 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 --- 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;