From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
stable@dpdk.org, Ajit Khaparde <ajit.khaparde@broadcom.com>,
Somnath Kotur <somnath.kotur@broadcom.com>,
Kishore Padmanabha <kishore.padmanabha@broadcom.com>,
Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>,
Mike Baucom <michael.baucom@broadcom.com>
Subject: [PATCH 5/7] net/bnxt: fix uninitialized warning
Date: Sun, 28 Dec 2025 10:40:18 -0800 [thread overview]
Message-ID: <20251228184300.541639-6-stephen@networkplumber.org> (raw)
In-Reply-To: <20251228184300.541639-1-stephen@networkplumber.org>
With gcc-16 it inlines a lot more code and creates a warnings
where it thinks it might be manipulating bits that are not set.
It looks like this is because the bits in control word (cword)
in theory could be larger than the variable. Should not
be possible because wc_ctl_size_bits is only set to 3, 16, or 32
but that happens outside of the scope of these functions.
Resolve by adding bounds check which compiler sees and knows
the loop will only see those bits.
In function ‘ulp_bs_push_msb’,
inlined from ‘ulp_blob_push’ at ../drivers/net/bnxt/tf_ulp/ulp_utils.h:407:8,
inlined from ‘ulp_blob_push_32’ at ../drivers/net/bnxt/tf_ulp/ulp_utils.h:551:7,
inlined from ‘ulp_mapper_wc_tcam_tbl_dyn_post_process’ at ../drivers/net/bnxt/tf_ulp/ulp_mapper.c:2487:9:
../drivers/net/bnxt/tf_ulp/ulp_utils.h:336:17: warning: ‘cword’ may be used uninitialized [-Wmaybe-uninitialized]
336 | ulp_bs_put_msb(bs, pos, 8, val[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/bnxt/tf_ulp/ulp_mapper.c: In function ‘ulp_mapper_wc_tcam_tbl_dyn_post_process’:
../drivers/net/bnxt/tf_ulp/ulp_mapper.c:2443:18: note: ‘cword’ declared here
2443 | uint32_t cword, i, rc;
| ^~~~~
Bugzilla ID: 1821
Fixes: 3fe124d2536c ("net/bnxt: support Thor platform")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/bnxt/tf_ulp/ulp_mapper.c | 5 +++++
drivers/net/bnxt/tf_ulp/ulp_mapper_tfc.c | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index 0ff952950b..960cdda311 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -2446,6 +2446,11 @@ ulp_mapper_wc_tcam_tbl_dyn_post_process(struct bnxt_ulp_device_params *dparms,
slice_width = dparms->wc_slice_width;
clen = dparms->wc_ctl_size_bits;
+ if (clen > 32) {
+ BNXT_DRV_DBG(ERR, "Key size bits %d too large\n", clen);
+ return -EINVAL;
+ }
+
max_slices = dparms->wc_max_slices;
blen = ulp_blob_data_len_get(key);
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper_tfc.c b/drivers/net/bnxt/tf_ulp/ulp_mapper_tfc.c
index f99698a1d8..2d89f10d5e 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper_tfc.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper_tfc.c
@@ -90,6 +90,10 @@ ulp_mapper_tfc_wc_tcam_post_process(struct bnxt_ulp_device_params *dparms,
slice_width = dparms->wc_slice_width;
clen = dparms->wc_ctl_size_bits;
+ if (clen > 32) {
+ BNXT_DRV_DBG(ERR, "Key size bits %d too large\n", clen);
+ return -EINVAL;
+ }
max_slices = dparms->wc_max_slices;
blen = ulp_blob_data_len_get(key);
--
2.51.0
next prev parent reply other threads:[~2025-12-28 18:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-28 18:40 [PATCH 0/7] Fix build with gcc-16 Stephen Hemminger
2025-12-28 18:40 ` [PATCH 1/7] pcapng: use alloca instead of fixed buffer Stephen Hemminger
2025-12-28 18:40 ` [PATCH 2/7] pcapng: add additional mbuf if space required on copy Stephen Hemminger
2025-12-28 18:40 ` [PATCH 3/7] test: add more tests for comments in pcapng Stephen Hemminger
2025-12-28 18:40 ` [PATCH 4/7] test: vary size of packets in pcapng test Stephen Hemminger
2025-12-28 18:40 ` Stephen Hemminger [this message]
2025-12-28 18:40 ` [PATCH 6/7] common/cnxk: fix array out of bounds Stephen Hemminger
2025-12-28 18:40 ` [PATCH 7/7] examples/fips_validation: avoid rte_memcpy alignment restriction Stephen Hemminger
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=20251228184300.541639-6-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=ajit.khaparde@broadcom.com \
--cc=dev@dpdk.org \
--cc=kishore.padmanabha@broadcom.com \
--cc=michael.baucom@broadcom.com \
--cc=somnath.kotur@broadcom.com \
--cc=stable@dpdk.org \
--cc=venkatkumar.duvvuru@broadcom.com \
/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).