From 767b4575342dbaf8aa0e6a3e7d5b36ee783c3c89 Mon Sep 17 00:00:00 2001 From: Gokul Sriram Palanisamy Date: Fri, 1 Sep 2017 16:02:50 +0530 Subject: [PATCH] ipq807x: Fix KW issues in sysupgrade.c and cmd_bootqca.c Change-Id: I665f3d596cf235be7347faf68f0bf1ea8b10de7a Signed-off-by: Gokul Sriram Palanisamy --- board/qca/arm/common/cmd_bootqca.c | 13 +++++++++---- tools/sysupgrade.c | 12 ++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/board/qca/arm/common/cmd_bootqca.c b/board/qca/arm/common/cmd_bootqca.c index 7bb5f7f258..0efd20db7b 100644 --- a/board/qca/arm/common/cmd_bootqca.c +++ b/board/qca/arm/common/cmd_bootqca.c @@ -363,6 +363,11 @@ int config_select(unsigned int addr, char *rcmd, int rcmd_size) int soc_version = 0; const char *config = fdt_getprop(gd->fdt_blob, 0, "config_name", NULL); + if(config == NULL) { + printf("Failed to get config_name\n"); + return -1; + } + sprintf((char *)dtb_config_name, "%s", config); ipq_smem_get_socinfo_version((uint32_t *)&soc_version); @@ -447,7 +452,7 @@ static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const a request); if (debug) - printf(runcmd); + printf("%s", runcmd); if (run_command(runcmd, 0) != CMD_RET_SUCCESS) return CMD_RET_FAILURE; @@ -494,7 +499,7 @@ static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const a request, sfi->hlos.offset, sfi->hlos.size); if (debug) - printf(runcmd); + printf("%s", runcmd); if (run_command(runcmd, 0) != CMD_RET_SUCCESS) return CMD_RET_FAILURE; @@ -529,7 +534,7 @@ static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const a ret = config_select(request, runcmd, sizeof(runcmd)); if (debug) - printf(runcmd); + printf("%s", runcmd); if (ret < 0 || run_command(runcmd, 0) != CMD_RET_SUCCESS) { #ifdef CONFIG_QCA_MMC @@ -712,7 +717,7 @@ static int do_boot_unsignedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const static int do_bootipq(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { int ret; - char buf; + char buf = 0; /* * set fdt_high parameter so that u-boot will not load * dtb above CONFIG_IPQ40XX_FDT_HIGH region. diff --git a/tools/sysupgrade.c b/tools/sysupgrade.c index 399f761ea2..368a4f1cad 100644 --- a/tools/sysupgrade.c +++ b/tools/sysupgrade.c @@ -126,6 +126,7 @@ int check_mbn_elf(struct image_section **sec) return 0; } + memset(&sb, 0, sizeof(struct stat)); if (fstat(fd, &sb) == -1) { perror("fstat"); close(fd); @@ -242,6 +243,7 @@ int get_local_image_version(struct image_section *section) return 0; } + memset(&st, 0, sizeof(struct stat)); fstat(fd, &st); len = st.st_size < sizeof(local_version_string) - 1 ? st.st_size : @@ -278,6 +280,11 @@ int set_local_image_version(struct image_section *section) } len = snprintf(version_string, 8, "%d", section->img_version); + if (len < 0) { + printf("Error in formatting the version string"); + return 0; + } + printf("Version to be updated:%s\n", version_string); if (write(fd, version_string, len) == -1) { printf("Error writing version to %s\n", version_file); @@ -348,6 +355,7 @@ int get_sw_id_from_component_bin(struct image_section *section) return 0; } + memset(&sb, 0, sizeof(struct stat)); if (fstat(fd, &sb) == -1) { perror("fstat"); close(fd); @@ -400,6 +408,7 @@ int process_elf(char *bin_file, uint8_t **fp, Elf32_Ehdr **elf, Elf32_Phdr **phd return 0; } + memset(&sb, 0, sizeof(struct stat)); if (fstat(fd, &sb) == -1) { perror("fstat"); close(fd); @@ -555,6 +564,7 @@ int extract_kernel_binary(struct image_section *section) return 0; } + memset(&sb, 0, sizeof(struct stat)); if (fstat(fd, &sb) == -1) { perror("fstat"); close(fd); @@ -720,6 +730,7 @@ int split_code_signature_cert_from_component_bin(struct image_section *section, return 0; } + memset(&sb, 0, sizeof(struct stat)); if (fstat(fd, &sb) == -1) { perror("fstat"); close(fd); @@ -928,6 +939,7 @@ char *read_file(char *file_name) return NULL; } + memset(&st, 0, sizeof(struct stat)); fstat(fd, &st); buffer = malloc(st.st_size * sizeof(buffer)); if (buffer == NULL) {