mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-21 22:51:37 +00:00
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 <wd@denx.de>
This commit is contained in:
parent
3699c28e6d
commit
2697eff1af
1 changed files with 13 additions and 8 deletions
|
@ -837,14 +837,16 @@ static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_
|
||||||
u32 offset;
|
u32 offset;
|
||||||
int err = 1;
|
int err = 1;
|
||||||
|
|
||||||
p = mtd_dev;
|
|
||||||
*retdev = NULL;
|
|
||||||
*ret = NULL;
|
|
||||||
|
|
||||||
DEBUGF("===device_parse===\n");
|
DEBUGF("===device_parse===\n");
|
||||||
|
|
||||||
|
assert(retdev);
|
||||||
|
*retdev = NULL;
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
*ret = NULL;
|
||||||
|
|
||||||
/* fetch <mtd-id> */
|
/* fetch <mtd-id> */
|
||||||
mtd_id = p;
|
mtd_id = p = mtd_dev;
|
||||||
if (!(p = strchr(mtd_id, ':'))) {
|
if (!(p = strchr(mtd_id, ':'))) {
|
||||||
printf("no <mtd-id> identifier\n");
|
printf("no <mtd-id> identifier\n");
|
||||||
return 1;
|
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 */
|
/* check for next device presence */
|
||||||
if (p) {
|
if (p) {
|
||||||
if (*p == ';') {
|
if (*p == ';') {
|
||||||
*ret = ++p;
|
if (ret)
|
||||||
|
*ret = ++p;
|
||||||
} else if (*p == '\0') {
|
} else if (*p == '\0') {
|
||||||
*ret = p;
|
if (ret)
|
||||||
|
*ret = p;
|
||||||
} else {
|
} else {
|
||||||
printf("unexpected character '%c' at the end of device\n", *p);
|
printf("unexpected character '%c' at the end of device\n", *p);
|
||||||
*ret = NULL;
|
if (ret)
|
||||||
|
*ret = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue