Skip to contentSkip to conversation

mtd: nand: complete nand_register() arguments check

PATCH In review Dario Binacchi 2 participants 2 messages Nov 2, 2023 – Nov 13, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: nand: complete nand_register() arguments check

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

---

 drivers/mtd/nand/raw/nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/nand.c +1 -1
index eacd99c4e275..d31bb580c46a 100644
@@ -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;
Signature · 1 line
2.42.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Dario Binacchi

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

---

 drivers/mtd/nand/raw/nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/nand.c +1 -2
index eacd99c4e275..d31bb580c46a 100644
@@ -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;
--
Quoted 2 lines

2.42.0

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com