fm10k: Validate VLAN ID in fm10k_update_xc_addr_pf
authorMatthew Vick <matthew.vick@intel.com>
Tue, 27 Jan 2015 02:33:26 +0000 (02:33 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Fri, 6 Feb 2015 03:41:50 +0000 (19:41 -0800)
Currently, fm10k_update_xc_addr_pf has an issue where it does not
properly drop the upper-most four bits of the VLAN ID due to type
promotion. Resolve the issue not by masking off the bits, but by
throwing an error if the VLAN ID is out-of-bounds.

Reported-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Matthew Vick <matthew.vick@intel.com>
Tested-by: Krishneil Singh <Krishneil.k.singh@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/fm10k/fm10k_pf.c

index 275423d4f77778911b71145dfd165de6dcb8d2ca..7e4711958e463a959c69365fdb3d5c9ff956f3e4 100644 (file)
@@ -330,13 +330,10 @@ static s32 fm10k_update_xc_addr_pf(struct fm10k_hw *hw, u16 glort,
        struct fm10k_mac_update mac_update;
        u32 msg[5];
 
-       /* if glort is not valid return error */
-       if (!fm10k_glort_valid_pf(hw, glort))
+       /* if glort or vlan are not valid return error */
+       if (!fm10k_glort_valid_pf(hw, glort) || vid >= FM10K_VLAN_TABLE_VID_MAX)
                return FM10K_ERR_PARAM;
 
-       /* drop upper 4 bits of VLAN ID */
-       vid = (vid << 4) >> 4;
-
        /* record fields */
        mac_update.mac_lower = cpu_to_le32(((u32)mac[2] << 24) |
                                                 ((u32)mac[3] << 16) |