i40iw: Fix potential fcn_id_array out of bounds
authorChristopher N Bednarz <christopher.n.bednarz@intel.com>
Wed, 9 Aug 2017 01:38:48 +0000 (20:38 -0500)
committerDoug Ledford <dledford@redhat.com>
Wed, 16 Aug 2017 15:27:44 +0000 (11:27 -0400)
Avoid out of bounds error by utilizing I40IW_MAX_STATS_COUNT
instead of I40IW_INVALID_FCN_ID.

Signed-off-by: Christopher N Bednarz <christoper.n.bednarz@intel.com>
Signed-off-by: Henry Orosco <henry.orosco@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/i40iw/i40iw_ctrl.c

index ef4a73cd17109959930ea9a10b280e07772a2276..a49ff2eb6fb3bca54f40bc460238eeb4a5b4ba52 100644 (file)
@@ -4881,7 +4881,7 @@ void i40iw_vsi_stats_free(struct i40iw_sc_vsi *vsi)
 {
        u8 fcn_id = vsi->fcn_id;
 
-       if ((vsi->stats_fcn_id_alloc) && (fcn_id != I40IW_INVALID_FCN_ID))
+       if (vsi->stats_fcn_id_alloc && fcn_id < I40IW_MAX_STATS_COUNT)
                vsi->dev->fcn_id_array[fcn_id] = false;
        i40iw_hw_stats_stop_timer(vsi);
 }