Skip to content
Snippets Groups Projects
Commit 01c42d3d authored by Siva Durga Prasad Paladugu's avatar Siva Durga Prasad Paladugu Committed by Michal Simek
Browse files

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: default avatarSiva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
parent 3c0e607c
No related branches found
No related tags found
No related merge requests found
...@@ -346,6 +346,7 @@ int board_late_init(void) ...@@ -346,6 +346,7 @@ int board_late_init(void)
u8 bootmode; u8 bootmode;
const char *mode; const char *mode;
char *new_targets; char *new_targets;
char *env_targets;
int ret; int ret;
if (!(gd->flags & GD_FLG_ENV_DEFAULT)) { if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
...@@ -418,10 +419,16 @@ int board_late_init(void) ...@@ -418,10 +419,16 @@ int board_late_init(void)
* One terminating char + one byte for space between mode * One terminating char + one byte for space between mode
* and default boot_targets * and default boot_targets
*/ */
new_targets = calloc(1, strlen(mode) + env_targets = env_get("boot_targets");
strlen(env_get("boot_targets")) + 2); 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); env_set("boot_targets", new_targets);
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment