Skip to contentSkip to conversation

i40e: don't truncate match_method assignment

PATCH Applied Jacob Keller 2 participants 3 messages Dec 9, 2016 – Dec 11, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i40e: don't truncate match_method assignment

The .match_method field is a u8, so we shouldn't be casting to a u16, and because it is only one byte, we do not need to byte swap anything. Just assign the value directly. This avoids issues on Big Endian architectures which would have byte swapped and then incorrectly truncated the value.

Cc Stephen Rothwell <[email protected]>
Cc Bimmy Pujari <[email protected]>

---
Not sure if this was already in Jeff's queue, but since it's an obvious fix for the issue found by Stephen, I thought I'd send it out now just to make sure. Thanks for catching this, and sorry we didn't find the fix earlier.

 drivers/net/ethernet/intel/i40e/i40e_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -2
index 69a51a4119d6..6ccf18464339 100644
@@ -2257,8 +2257,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
 			}
 			add_list[num_add].queue_number = 0;
 			/* set invalid match method for later detection */
-			add_list[num_add].match_method =
-				cpu_to_le16((u16)I40E_AQC_MM_ERR_NO_RES);
+			add_list[num_add].match_method = I40E_AQC_MM_ERR_NO_RES;
 			cmd_flags |= I40E_AQC_MACVLAN_ADD_PERFECT_MATCH;
 			add_list[num_add].flags = cpu_to_le16(cmd_flags);
 			num_add++;
Signature · 1 line
2.11.0.rc2.152.g4d04e67
maintainer
#1 lore raw

From: Jacob Keller <[email protected]>
Date: Fri, 9 Dec 2016 13:39:21 -0800

Quoted 6 lines

The .match_method field is a u8, so we shouldn't be casting to a u16, and because it is only one byte, we do not need to byte swap anything. Just assign the value directly. This avoids issues on Big Endian architectures which would have byte swapped and then incorrectly truncated the value.

Quoted 8 lines
Cc Stephen Rothwell <[email protected]>
Cc Bimmy Pujari <[email protected]>

---
Not sure if this was already in Jeff's queue, but since it's an obvious fix for the issue found by Stephen, I thought I'd send it out now just to make sure. Thanks for catching this, and sorry we didn't find the fix earlier.

Jeff, what do you want me to do with this?

maintainer Applied
#2 lore raw
In reply to Jacob Keller

From: Jacob Keller <[email protected]>
Date: Fri, 9 Dec 2016 13:39:21 -0800

Quoted 7 lines

The .match_method field is a u8, so we shouldn't be casting to a u16, and because it is only one byte, we do not need to byte swap anything. Just assign the value directly. This avoids issues on Big Endian architectures which would have byte swapped and then incorrectly truncated the value.

Applied.