Message ID | 1468348114-11442-15-git-send-email-ladis@linux-mips.org |
---|---|
State | Accepted |
Delegated to: | Tom Rini |
Headers | show |
On Tue, Jul 12, 2016 at 08:28:22PM +0200, Ladislav Michl wrote: > 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> Applied to u-boot/master, thanks!
diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c index 44b2c3a..3a88a10 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");
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> --- Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None cmd/mtdparts.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)