i40e: prevent memory leak in i40e_setup_macvlans
Subsystems (4)
PATCH 1/1 i40e: prevent memory leak in i40e_setup_macvlans
In i40e_setup_macvlans if i40e_setup_channel fails the allocated memory for ch should be released.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
@@ -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;
Signature · 1 line
2.17.1
Quoted 2 lines
In
i40e_setup_macvlansifi40e_setup_channelfails the allocated memory for ch should be released.
I suggest to improve also this change description.
drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_setup_macvlans(struct i40e_vsi *vsi, u16 macvlan_cnt, u16 qcnt, · line 7174
Quoted 9 lines
+++
b/drivers/net/ethernet/intel/i40e/i40e_main.cdrivers/net/ethernet/intel/i40e/i40e_main.c +1
-0@@ -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;
Can it matter to perform the added function call before the error code assignment?
Regards,
Markus
Quoted 11 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Navid Emamdoost
Sent: Wednesday, September 25, 2019 8:49 AM
Cc: netdev at vger.kernel.org; kjlu at umn.edu; linux-kernel at vger.kernel.org; emamd001 at umn.edu; intel-wired-lan at lists.osuosl.org;
smccaman at umn.edu; David S. Miller <[email protected]>; Navid Emamdoost <[email protected]>
Subject: [Intel-wired-lan] [PATCH] i40e: prevent memory leak ini40e_setup_macvlans
Quoted 7 lines
In
i40e_setup_macvlansifi40e_setup_channelfails the allocated memory for ch should be released.Signed-off-by Navid Emamdoost <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + 1 file changed, 1 insertion(+)