]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mtd: nand: complete nand_register() arguments check
authorDario Binacchi <dario.binacchi@amarulasolutions.com>
Thu, 2 Nov 2023 11:27:33 +0000 (12:27 +0100)
committerDario Binacchi <dario.binacchi@amarulasolutions.com>
Mon, 15 Jan 2024 07:58:24 +0000 (08:58 +0100)
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
drivers/mtd/nand/raw/nand.c

index 4c18861aa25a6e6dd428ed3894f2f9295edfd9e7..c1a0ebe6486a55b5e7734319d5947ff08bd542f3 100644 (file)
@@ -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;