Re: [U-Boot] [PATCH 1/2] mtdparts: fix write through NULL pointer
Wolfgang Denk wrote: > I tend to prefer my version, as it seems to be more defensive, and it > also adds an assert() for the 3rd parameter. > > If you agree, I'll apply my version? Yes, of course. Best regards, Stefano Babic -- = DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] mtdparts: fix write through NULL pointer
Dear Stefano Babic, In message <4bd81816.2050...@denx.de> you wrote: > > I have already sent a patch fixing this issue, I've seen it (unfortunately only after running into this myself). > http://lists.denx.de/pipermail/u-boot/2010-April/070347.html > > However, I preferred (easier way) to fix the calling function as the > device_parse(). I do not know if Stefan has already merged it. I tend to prefer my version, as it seems to be more defensive, and it also adds an assert() for the 3rd parameter. If you agree, I'll apply my version? Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Don't you know anything? I should have thought anyone knows that who knows anything about anything... - Terry Pratchett, _Soul Music_ ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] mtdparts: fix write through NULL pointer
Hi Stefano, On Wednesday 28 April 2010 13:12:22 Stefano Babic wrote: > > The "mtdparts add" command wrote through a NULL pointer - on many > > systems this went unnoticed (PowerPC has writable RAM there, some ARM > > systems have ROM where a write has no effect), but on arm1136 > > (i.MX31) it crashed the system. > > > > Add appropriate checks. > > Hi Wolfgang, > > I have already sent a patch fixing this issue, > > http://lists.denx.de/pipermail/u-boot/2010-April/070347.html > > However, I preferred (easier way) to fix the calling function as the > device_parse(). I do not know if Stefan has already merged it. No, I haven't merged it. Since I was not sure if this has to go through one of my git repositories. Both cfi-flash and ubi don't really include this mtdparts stuff. Wolfgang, I suggest you apply your preferred version directly. Thanks. Cheers, Stefan -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: off...@denx.de ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] mtdparts: fix write through NULL pointer
Wolfgang Denk wrote: > The "mtdparts add" command wrote through a NULL pointer - on many > systems this went unnoticed (PowerPC has writable RAM there, some ARM > systems have ROM where a write has no effect), but on arm1136 > (i.MX31) it crashed the system. > > Add appropriate checks. > Hi Wolfgang, I have already sent a patch fixing this issue, http://lists.denx.de/pipermail/u-boot/2010-April/070347.html However, I preferred (easier way) to fix the calling function as the device_parse(). I do not know if Stefan has already merged it. Stefano -- = DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 1/2] mtdparts: fix write through NULL pointer
The "mtdparts add" command wrote through a NULL pointer - on many systems this went unnoticed (PowerPC has writable RAM there, some ARM systems have ROM where a write has no effect), but on arm1136 (i.MX31) it crashed the system. Add appropriate checks. Signed-off-by: Wolfgang Denk --- common/cmd_mtdparts.c | 19 --- 1 files changed, 12 insertions(+), 7 deletions(-) diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c index 0b5f747..cec154c 100644 --- a/common/cmd_mtdparts.c +++ b/common/cmd_mtdparts.c @@ -837,14 +837,16 @@ static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_ u32 offset; int err = 1; - p = mtd_dev; + DEBUGF("===device_parse===\n"); + + assert(retdev); *retdev = NULL; - *ret = NULL; - DEBUGF("===device_parse===\n"); + if (ret) + *ret = NULL; /* fetch */ - mtd_id = p; + mtd_id = p = mtd_dev; if (!(p = strchr(mtd_id, ':'))) { printf("no identifier\n"); return 1; @@ -913,12 +915,15 @@ static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_ /* check for next device presence */ if (p) { if (*p == ';') { - *ret = ++p; + if (ret) + *ret = ++p; } else if (*p == '\0') { - *ret = p; + if (ret) + *ret = p; } else { printf("unexpected character '%c' at the end of device\n", *p); - *ret = NULL; + if (ret) + *ret = NULL; return 1; } } -- 1.6.2.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot