DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] pmdinfogen: Resolve coverity scan forward null issue
@ 2017-01-05 19:22 Neil Horman
  2017-01-06 10:41 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Neil Horman @ 2017-01-05 19:22 UTC (permalink / raw)
  To: dev; +Cc: Neil Horman, Neil Horman, john.mcnamara, thomas.monjalon

From: Neil Horman <nhorman@redhat.com>

Coverity issue 139593 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.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: john.mcnamara@intel.com
CC: thomas.monjalon@6wind.com
---
 buildtools/pmdinfogen/pmdinfogen.c | 15 ++++++++-------
 1 file 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) {
-- 
2.9.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-06 10:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-05 19:22 [dpdk-dev] [PATCH] pmdinfogen: Resolve coverity scan forward null issue Neil Horman
2017-01-06 10:41 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).