Skip to contentSkip to conversation

i40e: fix memcmp of pointer in i40e_hw_set_dcb_config()

PATCH In review Aaron Esau 3 participants 3 messages Mar 29 – May 6

Subsystems (4)
lore
Share & tools
lore

Aaron Esau

author
#0 lore raw

PATCH 1/1 i40e: fix memcmp of pointer in i40e_hw_set_dcb_config()

In i40e_hw_set_dcb_config(), both new_cfg and old_cfg are pointers to struct i40e_dcbx_config, so sizeof(new_cfg) evaluates to the size of a pointer (8 bytes on 64-bit) rather than the size of the struct. Likewise, &new_cfg and &old_cfg are the addresses of the pointer variables on the stack, not the addresses of the actual config structs.

As a result, the memcmp never compares the actual configuration data, meaning the "no change needed" early return never fires. Every call to this function performs a full DCB reconfiguration (quiescing all VSIs, reprogramming via "Set LLDP MIB" AQC, and reconfiguring VEB/VSIs) even when the configuration has not changed.

Fix this by comparing the structs themselves rather than the pointers.

Fixes 4b208eaa8078 ("i40e: Add init and default config of software based DCB")

---

Found using Coccinelle/spatch with a semantic patch that matches sizeof(ptr) and &ptr used together where ptr is a pointer type.

 drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
index XXXXXXX..XXXXXXX 100644
@@ -6904,7 +6904,7 @@ static int i40e_hw_set_dcb_config(struct i40e_pf *pf,
 	int ret;
 
 	/* Check if need reconfiguration */
-	if (!memcmp(&new_cfg, &old_cfg, sizeof(new_cfg))) {
+	if (!memcmp(new_cfg, old_cfg, sizeof(*new_cfg))) {
 		dev_dbg(&pf->pdev->dev, "No Change in DCB Config required.\n");
 		return 0;
 	}

--
2.49.0

Reviewed-by on v1 1/1
#1 lore raw
Quoted 59 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Aaron Esau
Sent: Sunday, March 29, 2026 6:22 PM
To: [email protected]
Cc: [email protected]; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Kubalewski, Arkadiusz <[email protected]>; [email protected]; Aaron Esau <[email protected]>
Subject: [Intel-wired-lan] [PATCH net] i40e: fix memcmp of pointer in i40e_hw_set_dcb_config()

In i40e_hw_set_dcb_config(), both new_cfg and old_cfg are pointers to struct i40e_dcbx_config, so sizeof(new_cfg) evaluates to the size of a pointer (8 bytes on 64-bit) rather than the size of the struct. Likewise, &new_cfg and &old_cfg are the addresses of the pointer variables on the stack, not the addresses of the actual config structs.

As a result, the memcmp never compares the actual configuration data, meaning the "no change needed" early return never fires. Every call to this function performs a full DCB reconfiguration (quiescing all VSIs, reprogramming via "Set LLDP MIB" AQC, and reconfiguring VEB/VSIs) even when the configuration has not changed.

Fix this by comparing the structs themselves rather than the pointers.

Fixes 4b208eaa8078 ("i40e: Add init and default config of software

based DCB")

---

Found using Coccinelle/spatch with a semantic patch that matches sizeof(ptr) and &ptr used together where ptr is a pointer type.

 drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
index XXXXXXX..XXXXXXX 100644
@@ -6904,7 +6904,7 @@ static int i40e_hw_set_dcb_config(struct i40e_pf
 *pf,
 	int ret;
 
 	/* Check if need reconfiguration */
-	if (!memcmp(&new_cfg, &old_cfg, sizeof(new_cfg))) {
+	if (!memcmp(new_cfg, old_cfg, sizeof(*new_cfg))) {
 		dev_dbg(&pf->pdev->dev, "No Change in DCB Config
 required.\n");
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -1
 		return 0;
 	}
--
Quoted 1 line

2.49.0

Tested-by on v1 1/1
#2 lore raw
In reply to Aaron Esau
Quoted 16 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Aaron Esau
Sent: Sunday, March 29, 2026 9:52 PM
To: [email protected]
Cc: [email protected]; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Kubalewski, Arkadiusz <[email protected]>; [email protected]; Aaron Esau <[email protected]>
Subject: [Intel-wired-lan] [PATCH net] i40e: fix memcmp of pointer in i40e_hw_set_dcb_config()

In i40e_hw_set_dcb_config(), both new_cfg and old_cfg are pointers to struct i40e_dcbx_config, so sizeof(new_cfg) evaluates to the size of a pointer (8 bytes on 64-bit) rather than the size of the struct. > Likewise, &new_cfg and &old_cfg are the addresses of the pointer variables on the stack, not the addresses of the actual config structs.

As a result, the memcmp never compares the actual configuration data, meaning the "no change needed" early return never fires. Every call to this function performs a full DCB reconfiguration (quiescing > all VSIs, reprogramming via "Set LLDP MIB" AQC, and reconfiguring VEB/VSIs) even when the configuration has not changed.

Fix this by comparing the structs themselves rather than the pointers.

Fixes 4b208eaa8078 ("i40e: Add init and default config of software based DCB")
Quoted 8 lines

---

Found using Coccinelle/spatch with a semantic patch that matches sizeof(ptr) and &ptr used together where ptr is a pointer type.

 drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)