[U-Boot] [PATCH] mtdparts add not working

Stefano Babic sbabic at denx.de
Wed Apr 21 09:47:02 CEST 2010


Adding a new partition using the mtdparts command
causes a null pointer access because the device_parse
function does not accept a null pointer as parameter.

Signed-off-by: Stefano Babic <sbabic at denx.de>
---
 common/cmd_mtdparts.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
index 0b5f747..5f88fb9 100644
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -1795,6 +1795,7 @@ int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		struct mtd_device *dev_tmp;
 		struct mtdids *id;
 		struct part_info *p;
+		const char dummy, *pdummy;
 
 		if (mtd_id_parse(argv[2], NULL, &type, &num) != 0)
 			return 1;
@@ -1818,7 +1819,8 @@ int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 				id->mtd_id, argv[3], argv[4], argv[5] ? argv[5] : "");
 		DEBUGF("add tmpbuf: %s\n", tmpbuf);
 
-		if ((device_parse(tmpbuf, NULL, &dev) != 0) || (!dev))
+		pdummy = &dummy;
+		if ((device_parse(tmpbuf, &pdummy, &dev) != 0) || (!dev))
 			return 1;
 
 		DEBUGF("+ %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type),
-- 
1.6.3.3



More information about the U-Boot mailing list