Skip to contentSkip to conversation

net/netvsc: fix bogus sizeof calculation

PATCH Applied [email protected] 3 participants 3 messages Jun 29, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/netvsc: fix bogus sizeof calculation

From: Stephen Hemminger <[email protected]>

Found by cppcheck.

drivers/net/netvsc/hn_rndis.c:332:21: warning: Found calculation inside sizeof(). [sizeofCalculation] if (len < sizeof(3 * sizeof(uint32_t))) {

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
---
 drivers/net/netvsc/hn_rndis.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/netvsc/hn_rndis.c +2 -1
index e6f1f28768..29c6009b2c 100644
@@ -329,7 +329,8 @@ void hn_rndis_receive_response(struct hn_data *hv,
 
 	hn_rndis_dump(data);
 
-	if (len < sizeof(3 * sizeof(uint32_t))) {
+	/* Check we can read first three data fields from RNDIS header */
+	if (len < 3 * sizeof(uint32_t)) {
 		PMD_DRV_LOG(ERR,
 			    "missing RNDIS header %u", len);
 		return;
Signature · 1 line
2.17.1
Applied
#1 lore raw
Quoted 10 lines · On 6/29/2023 1:29 AM, [email protected] wrote:

From: Stephen Hemminger <[email protected]>

Found by cppcheck.

drivers/net/netvsc/hn_rndis.c:332:21: warning: Found calculation inside sizeof(). [sizeofCalculation] if (len < sizeof(3 * sizeof(uint32_t))) {

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")

Applied to dpdk-next-net/main, thanks.

Acked-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 10 lines · On Wed, Jun 28, 2023 at 05:29:57PM -0700, [email protected] wrote:

From: Stephen Hemminger <[email protected]>

Found by cppcheck.

drivers/net/netvsc/hn_rndis.c:332:21: warning: Found calculation inside sizeof(). [sizeofCalculation] if (len < sizeof(3 * sizeof(uint32_t))) {

Fixes 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")

---