nfp: flower: prevent memory leak in nfp_flower_spawn_phy_reprs
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: b945245297
("nfp: flower: add per repr private data for LAG offload")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
dfe5999dc0
commit
8572cea146
|
@ -515,6 +515,7 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv)
|
|||
repr_priv = kzalloc(sizeof(*repr_priv), GFP_KERNEL);
|
||||
if (!repr_priv) {
|
||||
err = -ENOMEM;
|
||||
nfp_repr_free(repr);
|
||||
goto err_reprs_clean;
|
||||
}
|
||||
|
||||
|
@ -525,11 +526,13 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv)
|
|||
port = nfp_port_alloc(app, NFP_PORT_PHYS_PORT, repr);
|
||||
if (IS_ERR(port)) {
|
||||
err = PTR_ERR(port);
|
||||
kfree(repr_priv);
|
||||
nfp_repr_free(repr);
|
||||
goto err_reprs_clean;
|
||||
}
|
||||
err = nfp_port_init_phy_port(app->pf, app, port, i);
|
||||
if (err) {
|
||||
kfree(repr_priv);
|
||||
nfp_port_free(port);
|
||||
nfp_repr_free(repr);
|
||||
goto err_reprs_clean;
|
||||
|
@ -542,6 +545,7 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv)
|
|||
err = nfp_repr_init(app, repr,
|
||||
cmsg_port_id, port, priv->nn->dp.netdev);
|
||||
if (err) {
|
||||
kfree(repr_priv);
|
||||
nfp_port_free(port);
|
||||
nfp_repr_free(repr);
|
||||
goto err_reprs_clean;
|
||||
|
|
Loading…
Reference in New Issue