]> git.baikalelectronics.ru Git - kernel.git/commitdiff
nfp: flower: fix memory leak in nfp_flower_spawn_vnic_reprs
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Wed, 25 Sep 2019 19:05:09 +0000 (14:05 -0500)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Sep 2019 18:12:03 +0000 (20:12 +0200)
In nfp_flower_spawn_vnic_reprs in the loop if initialization or the
allocations fail memory is leaked. Appropriate releases are added.

Fixes: 8ccc0516eb17 ("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>
drivers/net/ethernet/netronome/nfp/flower/main.c

index 91a47899220f62f15f30b54646ccb89ee5319150..d8ad9346a26a48bfbc64610a811538299954b76a 100644 (file)
@@ -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;