i40e: Prevent overflow due to kzalloc
authorAkeem G Abodunrin <akeem.g.abodunrin@intel.com>
Thu, 6 Feb 2014 05:51:02 +0000 (05:51 +0000)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Fri, 7 Mar 2014 02:41:22 +0000 (18:41 -0800)
To prevent the possibility of overflow due multiplication of number and size
use kcalloc instead of kzalloc.

Change-ID: Ibe4d81ed7d9738d3bbe66ee4844ff9be817e8080
Signed-off-by: Akeem G Abodunrin <akeem.g.abodunrin@intel.com>
Signed-off-by: Catherine Sullivan <catherine.sullivan@intel.com>
Tested-by: Kavindya Deegala <kavindya.s.deegala@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

index 189e250198dd698f83d2ca8a9f188eb38c0ba970..42cc6ba880057df59b7be9442550545e1e2f7c24 100644 (file)
@@ -858,7 +858,7 @@ int i40e_alloc_vfs(struct i40e_pf *pf, u16 num_alloc_vfs)
                }
        }
        /* allocate memory */
-       vfs = kzalloc(num_alloc_vfs * sizeof(struct i40e_vf), GFP_KERNEL);
+       vfs = kcalloc(num_alloc_vfs, sizeof(struct i40e_vf), GFP_KERNEL);
        if (!vfs) {
                ret = -ENOMEM;
                goto err_alloc;