From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id 991DD3777 for ; Thu, 5 Jan 2017 20:23:53 +0100 (CET) Received: from cpe-2606-a000-111b-40ed-7aac-c0ff-fec2-933b.dyn6.twc.com ([2606:a000:111b:40ed:7aac:c0ff:fec2:933b] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1cPDdS-0006Q8-3T; Thu, 05 Jan 2017 14:23:50 -0500 From: Neil Horman To: dev@dpdk.org Cc: Neil Horman , Neil Horman , john.mcnamara@intel.com, thomas.monjalon@6wind.com Date: Thu, 5 Jan 2017 14:22:41 -0500 Message-Id: <20170105192241.29213-1-nhorman@tuxdriver.com> X-Mailer: git-send-email 2.9.3 X-Spam-Score: -2.9 (--) X-Spam-Status: No Subject: [dpdk-dev] [PATCH] pmdinfogen: Resolve coverity scan forward null issue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jan 2017 19:23:53 -0000 From: Neil Horman 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 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