Commit 5b6c791f authored by Navid Emamdoost's avatar Navid Emamdoost Committed by Greg Kroah-Hartman

nfp: flower: prevent memory leak in nfp_flower_spawn_phy_reprs

[ Upstream commit 8572cea1 ]

In nfp_flower_spawn_phy_reprs, in the for loop over eth_tbl if any of
intermediate allocations or initializations fail memory is leaked.
requiered releases are added.

Fixes: b9452452 ("nfp: flower: add per repr private data for LAG offload")
Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 33fe1f51
...@@ -259,6 +259,7 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app, ...@@ -259,6 +259,7 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app,
repr_priv = kzalloc(sizeof(*repr_priv), GFP_KERNEL); repr_priv = kzalloc(sizeof(*repr_priv), GFP_KERNEL);
if (!repr_priv) { if (!repr_priv) {
err = -ENOMEM; err = -ENOMEM;
nfp_repr_free(repr);
goto err_reprs_clean; goto err_reprs_clean;
} }
...@@ -291,6 +292,7 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app, ...@@ -291,6 +292,7 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app,
err = nfp_repr_init(app, repr, err = nfp_repr_init(app, repr,
port_id, port, priv->nn->dp.netdev); port_id, port, priv->nn->dp.netdev);
if (err) { if (err) {
kfree(repr_priv);
nfp_port_free(port); nfp_port_free(port);
nfp_repr_free(repr); nfp_repr_free(repr);
goto err_reprs_clean; goto err_reprs_clean;
...@@ -389,6 +391,7 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv) ...@@ -389,6 +391,7 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv)
} }
err = nfp_port_init_phy_port(app->pf, app, port, i); err = nfp_port_init_phy_port(app->pf, app, port, i);
if (err) { if (err) {
kfree(repr_priv);
nfp_port_free(port); nfp_port_free(port);
nfp_repr_free(repr); nfp_repr_free(repr);
goto err_reprs_clean; goto err_reprs_clean;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment