Commit c0ac3339475d3b6afc0cd901f20dd21d5fade17d
Committed by
Tom Rini
1 parent
52486927e7
Exists in
v2017.01-smarct4x
and in
25 other branches
cmd: mtdparts: fix mtdparts variable presence confusion in mtdparts_init
A private buffer is used to read mtdparts variable from non-relocated environment. A pointer to that buffer is returned unconditionally, confusing later test for variable presence in the environment. Fix it by returning NULL when getenv_f fails. Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Showing 1 changed file with 6 additions and 4 deletions Side-by-side Diff
cmd/mtdparts.c
... | ... | @@ -1720,11 +1720,13 @@ |
1720 | 1720 | * before the env is relocated, then we need to use our own stack |
1721 | 1721 | * buffer. gd->env_buf will be too small. |
1722 | 1722 | */ |
1723 | - if (gd->flags & GD_FLG_ENV_READY) { | |
1723 | + if (gd->flags & GD_FLG_ENV_READY) | |
1724 | 1724 | parts = getenv("mtdparts"); |
1725 | - } else { | |
1726 | - parts = tmp_parts; | |
1727 | - getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN); | |
1725 | + else { | |
1726 | + if (getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN) != -1) | |
1727 | + parts = tmp_parts; | |
1728 | + else | |
1729 | + parts = NULL; | |
1728 | 1730 | } |
1729 | 1731 | current_partition = getenv("partition"); |
1730 | 1732 |