From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Peng Zhang <peng.zhang@corigine.com>,
stable@dpdk.org, Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 8/8] net/nfp: fix tainted scalar
Date: Thu, 14 Mar 2024 15:05:36 +0800 [thread overview]
Message-ID: <20240314070536.3169210-9-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240314070536.3169210-1-chaoyong.he@corigine.com>
From: Peng Zhang <peng.zhang@corigine.com>
Passing tainted expression 'ectx->fw_info_strtab_sz' to
'nfp_elf_fwinfo_lookup()', which uses it as a loop boundary.
Replace tainted expression with a temp variable to avoid
the tainted scalar coverity warning.
Coverity issue: 415051
Fixes: c82ca09c441c ("net/nfp: add ELF module")
Cc: stable@dpdk.org
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/nfpcore/nfp_elf.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/nfp/nfpcore/nfp_elf.c b/drivers/net/nfp/nfpcore/nfp_elf.c
index 268cdb1aff..fab9b68801 100644
--- a/drivers/net/nfp/nfpcore/nfp_elf.c
+++ b/drivers/net/nfp/nfpcore/nfp_elf.c
@@ -324,14 +324,13 @@ nfp_elf_fwinfo_next(struct nfp_elf *ectx,
}
static const char *
-nfp_elf_fwinfo_lookup(struct nfp_elf *ectx,
+nfp_elf_fwinfo_lookup(const char *strtab,
+ ssize_t tab_sz,
const char *key)
{
size_t s_len;
const char *s;
size_t key_len = strlen(key);
- const char *strtab = ectx->fw_info_strtab;
- ssize_t tab_sz = (ssize_t)ectx->fw_info_strtab_sz;
if (strtab == NULL)
return NULL;
@@ -610,7 +609,9 @@ nfp_elf_populate_fw_mip(struct nfp_elf *ectx,
{
uint8_t *pu8;
const char *nx;
+ ssize_t tab_sz;
uint64_t sh_size;
+ const char *str_tab;
uint64_t sh_offset;
uint32_t first_entry;
const struct nfp_mip *mip;
@@ -662,7 +663,9 @@ nfp_elf_populate_fw_mip(struct nfp_elf *ectx,
}
}
- ectx->fw_mip.fw_typeid = nfp_elf_fwinfo_lookup(ectx, "TypeId");
+ str_tab = ectx->fw_info_strtab;
+ tab_sz = (ssize_t)ectx->fw_info_strtab_sz;
+ ectx->fw_mip.fw_typeid = nfp_elf_fwinfo_lookup(str_tab, tab_sz, "TypeId");
/*
* TypeId will be the last reserved key-value pair, so skip
--
2.39.1
next prev parent reply other threads:[~2024-03-14 7:07 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-14 7:05 [PATCH 0/8] fix some coverity issues Chaoyong He
2024-03-14 7:05 ` [PATCH 1/8] net/nfp: fix return value check Chaoyong He
2024-03-14 7:05 ` [PATCH 2/8] net/nfp: fix string overflow Chaoyong He
2024-03-14 7:05 ` [PATCH 3/8] net/nfp: fix unreachable control flow Chaoyong He
2024-03-14 7:05 ` [PATCH 4/8] net/nfp: fix check return value Chaoyong He
2024-03-14 7:05 ` [PATCH 5/8] net/nfp: fix unreachable loop flow Chaoyong He
2024-03-14 7:05 ` [PATCH 6/8] net/nfp: fix null pointer dereference Chaoyong He
2024-03-14 7:05 ` [PATCH 7/8] net/nfp: fix dereference after null check Chaoyong He
2024-03-14 7:05 ` Chaoyong He [this message]
2024-03-14 7:40 ` [PATCH v2 0/8] fix some coverity issues Chaoyong He
2024-03-14 7:40 ` [PATCH v2 1/8] net/nfp: fix return value check Chaoyong He
2024-03-14 7:40 ` [PATCH v2 2/8] net/nfp: fix string overflow Chaoyong He
2024-03-14 7:40 ` [PATCH v2 3/8] net/nfp: fix unreachable control flow Chaoyong He
2024-03-14 7:40 ` [PATCH v2 4/8] net/nfp: fix check return value Chaoyong He
2024-03-14 7:40 ` [PATCH v2 5/8] net/nfp: fix unreachable loop flow Chaoyong He
2024-03-14 7:40 ` [PATCH v2 6/8] net/nfp: fix null pointer dereference Chaoyong He
2024-03-14 7:40 ` [PATCH v2 7/8] net/nfp: fix dereference after null check Chaoyong He
2024-03-14 7:40 ` [PATCH v2 8/8] net/nfp: fix tainted scalar Chaoyong He
2024-03-14 11:01 ` [PATCH v2 0/8] fix some coverity issues Ferruh Yigit
2024-03-14 10:58 ` [PATCH " Ferruh Yigit
2024-03-14 11:01 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240314070536.3169210-9-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=oss-drivers@corigine.com \
--cc=peng.zhang@corigine.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).