Patchwork [U-Boot] cmd_bootm.c: Re-order bootm_load_os return check for ELDK4.2

login
register
mail settings
Submitter Tom Rini
Date July 11, 2013, 1:38 p.m.
Message ID <1373549884-17765-1-git-send-email-trini@ti.com>
Download mbox | patch
Permalink /patch/258456/
State Accepted
Headers show

Comments

Tom Rini - July 11, 2013, 1:38 p.m.
With ELDK4.2 we were getting a warning that load_end may be used
uninitialized in calling lmb_reserve.  This could not be the case,
however.  If we re-order the checks (and make them slightly clearer as
well) the warning goes away.  bootm_load_os may only return 0 on
success, BOOTM_ERR_OVERLAP in a non-fatal overlap (already covered in
comments) or a fatal BOOTM_ERR that is covered in the error handler.

Signed-off-by: Tom Rini <trini@ti.com>
---
 common/cmd_bootm.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Tom Rini - July 12, 2013, 9:24 p.m.
On Thu, Jul 11, 2013 at 09:38:04AM -0400, Tom Rini wrote:

> With ELDK4.2 we were getting a warning that load_end may be used
> uninitialized in calling lmb_reserve.  This could not be the case,
> however.  If we re-order the checks (and make them slightly clearer as
> well) the warning goes away.  bootm_load_os may only return 0 on
> success, BOOTM_ERR_OVERLAP in a non-fatal overlap (already covered in
> comments) or a fatal BOOTM_ERR that is covered in the error handler.
> 
> Signed-off-by: Tom Rini <trini@ti.com>

Applied to u-boot/master.

Patch

diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 6caa0e9..d5b2a3c 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -650,12 +650,11 @@  static int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc,
 
 		iflag = bootm_disable_interrupts();
 		ret = bootm_load_os(images, &load_end, 0);
-		if (ret && ret != BOOTM_ERR_OVERLAP)
-			goto err;
-
 		if (ret == 0)
 			lmb_reserve(&images->lmb, images->os.load,
 				    (load_end - images->os.load));
+		else if (ret && ret != BOOTM_ERR_OVERLAP)
+			goto err;
 		else if (ret == BOOTM_ERR_OVERLAP)
 			ret = 0;
 	}