i40e: Check for memory allocation failure
authorChristophe Jaillet <christophe.jaillet@wanadoo.fr>
Fri, 5 May 2017 19:29:13 +0000 (21:29 +0200)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Wed, 31 May 2017 10:13:36 +0000 (03:13 -0700)
If 'kzalloc' fails, a NULL pointer will be dereferenced. Return -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_client.c

index c3b81a9..088b4a4 100644 (file)
@@ -595,6 +595,8 @@ static int i40e_client_setup_qvlist(struct i40e_info *ldev,
        size = sizeof(struct i40e_qvlist_info) +
               (sizeof(struct i40e_qv_info) * (qvlist_info->num_vectors - 1));
        ldev->qvlist_info = kzalloc(size, GFP_KERNEL);
+       if (!ldev->qvlist_info)
+               return -ENOMEM;
        ldev->qvlist_info->num_vectors = qvlist_info->num_vectors;
 
        for (i = 0; i < qvlist_info->num_vectors; i++) {