i40e: Fix a potential NULL pointer dereference
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 6 Aug 2017 21:37:01 +0000 (23:37 +0200)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Mon, 2 Oct 2017 19:46:35 +0000 (12:46 -0700)
If 'kzalloc()' fails, a NULL pointer will be dereferenced.
Return an error code (-ENOMEM) instead.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

index e6b95e1e1a337106c882a91408ee60987323ce52..9e3667fc7f6ae14c58177ae1fd7c98d9e5521da9 100644 (file)
@@ -423,6 +423,9 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf,
               (sizeof(struct virtchnl_iwarp_qv_info) *
                                                (qvlist_info->num_vectors - 1));
        vf->qvlist_info = kzalloc(size, GFP_KERNEL);
+       if (!vf->qvlist_info)
+               return -ENOMEM;
+
        vf->qvlist_info->num_vectors = qvlist_info->num_vectors;
 
        msix_vf = pf->hw.func_caps.num_msix_vectors_vf;