i40e: prevent memory leak in i40e_setup_macvlans
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Wed, 25 Sep 2019 15:48:30 +0000 (10:48 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Jan 2020 07:22:52 +0000 (08:22 +0100)
[ Upstream commit 27d461333459d282ffa4a2bdb6b215a59d493a8f ]

In i40e_setup_macvlans if i40e_setup_channel fails the allocated memory
for ch should be released.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/intel/i40e/i40e_main.c

index 4960c9c..a8dd022 100644 (file)
@@ -7168,6 +7168,7 @@ static int i40e_setup_macvlans(struct i40e_vsi *vsi, u16 macvlan_cnt, u16 qcnt,
                ch->num_queue_pairs = qcnt;
                if (!i40e_setup_channel(pf, vsi, ch)) {
                        ret = -EINVAL;
+                       kfree(ch);
                        goto err_free;
                }
                ch->parent_vsi = vsi;