nfp: flower: fix memory leak in nfp_flower_spawn_vnic_reprs
Subsystems (4)
PATCH 1/1 nfp: flower: fix memory leak in nfp_flower_spawn_vnic_reprs
In nfp_flower_spawn_vnic_reprs in the loop if initialization or the allocations fail memory is leaked. Appropriate releases are added.
--- drivers/net/ethernet/netronome/nfp/flower/main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/netronome/nfp/flower/main.c +3 -0
@@ -400,6 +400,7 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app, repr_priv =kzalloc (sizeof (*repr_priv),GFP_KERNEL );if (!repr_priv) { err = -ENOMEM ; +nfp_repr_free (repr); goto err_reprs_clean; }
@@ -413,6 +414,7 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app, port =nfp_port_alloc (app, port_type, repr);if (IS_ERR (port)) { err =PTR_ERR (port); +kfree (repr_priv);nfp_repr_free (repr); goto err_reprs_clean; }
@@ -433,6 +435,7 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app, err =nfp_repr_init (app, repr, port_id, port, priv->nn->dp.netdev);if (err) { +kfree (repr_priv);nfp_port_free (port);nfp_repr_free (repr); goto err_reprs_clean;
Signature · 1 line
2.17.1
Quoted 4 lines · Navid Emamdoost
In
nfp_flower_spawn_vnic_reprsin the loop if initialization or the allocations fail memory is leaked. Appropriate releases are added.Signed-off-by Navid Emamdoost <[email protected]>
drivers/net/ethernet/netronome/nfp/flower/main.c nfp_flower_spawn_vnic_reprs(struct nfp_app *app, · line 441
Quoted 8 lines
drivers/net/ethernet/netronome/nfp/flower/main.c +1
-0@@ -433,6 +435,7 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app, err =nfp_repr_init (app, repr, port_id, port, priv->nn->dp.netdev);if (err) { +kfree (repr_priv);nfp_port_free (port);nfp_repr_free (repr); goto err_reprs_clean;
How do you think about to move common exception handling code to the end of this function implementation by using another jump target?
Regards,
Markus
From: Navid Emamdoost <[email protected]>
Date: Wed, 25 Sep 2019 14:05:09 -0500
Quoted 4 lines
In
nfp_flower_spawn_vnic_reprsin the loop if initialization or the allocations fail memory is leaked. Appropriate releases are added.Signed-off-by Navid Emamdoost <[email protected]>
Applied.