summaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
authorNeil Horman <nhorman@tuxdriver.com>2017-01-05 14:22:41 -0500
committerThomas Monjalon <thomas.monjalon@6wind.com>2017-01-06 11:40:30 +0100
commit348e470bc6be6f28fc197f6d2dc4f3cebb43e719 (patch)
tree5d80bda292470b41833798f86a6b1478aafb99eb /buildtools
parent86c743cf9140806ab9d61f63768e516aae477860 (diff)
downloaddpdk-348e470bc6be6f28fc197f6d2dc4f3cebb43e719.zip
dpdk-348e470bc6be6f28fc197f6d2dc4f3cebb43e719.tar.gz
dpdk-348e470bc6be6f28fc197f6d2dc4f3cebb43e719.tar.xz
pmdinfogen: fix null dereference
Coverity reports a forward null dereference from a for loop that works with a variable previously tested for null that had no error handling or condition to prevent it. Pretty obvious fix below. Coverity issue: 139593 Fixes: 98b0fdb0ffc6 ("pmdinfogen: add buildtools and pmdinfogen utility") Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/pmdinfogen/pmdinfogen.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/buildtools/pmdinfogen/pmdinfogen.c b/buildtools/pmdinfogen/pmdinfogen.c
index 5129c57..ba1a12e 100644
--- a/buildtools/pmdinfogen/pmdinfogen.c
+++ b/buildtools/pmdinfogen/pmdinfogen.c
@@ -226,13 +226,14 @@ static int parse_elf(struct elf_info *info, const char *filename)
}
if (!info->symtab_start)
fprintf(stderr, "%s has no symtab?\n", filename);
-
- /* Fix endianness in symbols */
- for (sym = info->symtab_start; sym < info->symtab_stop; sym++) {
- sym->st_shndx = TO_NATIVE(endian, 16, sym->st_shndx);
- sym->st_name = TO_NATIVE(endian, 32, sym->st_name);
- sym->st_value = TO_NATIVE(endian, ADDR_SIZE, sym->st_value);
- sym->st_size = TO_NATIVE(endian, ADDR_SIZE, sym->st_size);
+ else {
+ /* Fix endianness in symbols */
+ for (sym = info->symtab_start; sym < info->symtab_stop; sym++) {
+ sym->st_shndx = TO_NATIVE(endian, 16, sym->st_shndx);
+ sym->st_name = TO_NATIVE(endian, 32, sym->st_name);
+ sym->st_value = TO_NATIVE(endian, ADDR_SIZE, sym->st_value);
+ sym->st_size = TO_NATIVE(endian, ADDR_SIZE, sym->st_size);
+ }
}
if (symtab_shndx_idx != ~0U) {