diff options
author | Siva Durga Prasad Paladugu | 2017-12-20 16:35:06 +0530 |
---|---|---|
committer | Michal Simek | 2018-01-30 14:28:35 +0100 |
commit | 01c42d3d74cd51fd04da297898015d6b1ca00b28 (patch) | |
tree | d8f68b0a642c643f1796d30cc9103044c5334571 /board | |
parent | 3c0e607c31ff7fc324ef8b5d17ad532909f1faa1 (diff) |
xilinx: zynqmp: Use strlen only if env_get doesn't return null
Add check if boot_targets exists in environment and then
generate new_targets env accordingly. Performing strlen on
null address causes it to fail with exception if isolation
is enabled with DDR address zero as secure. It works with out
isolation enabled as zero is valid address but it may lead to
junk values in boot_targets.
This patch fixes the issue by checking return value of env_get
so that it generate boot_targets properly.
Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Diffstat (limited to 'board')
-rw-r--r-- | board/xilinx/zynqmp/zynqmp.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index c198a4d9206..8b6c0ea4669 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -346,6 +346,7 @@ int board_late_init(void) u8 bootmode; const char *mode; char *new_targets; + char *env_targets; int ret; if (!(gd->flags & GD_FLG_ENV_DEFAULT)) { @@ -418,10 +419,16 @@ int board_late_init(void) * One terminating char + one byte for space between mode * and default boot_targets */ - new_targets = calloc(1, strlen(mode) + - strlen(env_get("boot_targets")) + 2); + env_targets = env_get("boot_targets"); + if (env_targets) { + new_targets = calloc(1, strlen(mode) + + strlen(env_targets) + 2); + sprintf(new_targets, "%s %s", mode, env_targets); + } else { + new_targets = calloc(1, strlen(mode) + 2); + sprintf(new_targets, "%s", mode); + } - sprintf(new_targets, "%s %s", mode, env_get("boot_targets")); env_set("boot_targets", new_targets); return 0; |