aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorLadislav Michl <ladis@linux-mips.org>2016-07-12 20:28:22 +0200
committerTom Rini <trini@konsulko.com>2016-07-22 14:46:13 -0400
commitc0ac3339475d3b6afc0cd901f20dd21d5fade17d (patch)
tree52c2bcaa775bbc230370358ca51a235b098ebe5b /cmd
parent52486927e7f0c9ea2c5af32cc21496c908cae661 (diff)
downloadu-boot-midas-c0ac3339475d3b6afc0cd901f20dd21d5fade17d.tar.gz
u-boot-midas-c0ac3339475d3b6afc0cd901f20dd21d5fade17d.tar.bz2
u-boot-midas-c0ac3339475d3b6afc0cd901f20dd21d5fade17d.zip
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>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mtdparts.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index 44b2c3a5a9..3a88a10ba3 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -1720,11 +1720,13 @@ int mtdparts_init(void)
* before the env is relocated, then we need to use our own stack
* buffer. gd->env_buf will be too small.
*/
- if (gd->flags & GD_FLG_ENV_READY) {
+ if (gd->flags & GD_FLG_ENV_READY)
parts = getenv("mtdparts");
- } else {
- parts = tmp_parts;
- getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN);
+ else {
+ if (getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN) != -1)
+ parts = tmp_parts;
+ else
+ parts = NULL;
}
current_partition = getenv("partition");