Re: [PATCH] nfp: flower: prevent memory leak in nfp_flower_spawn_phy_reprs

From: Markus Elfring
Date: Fri Sep 27 2019 - 10:26:46 EST


> 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.

I suggest to improve also this change description.


> @@ -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;

How do you think about to move common exception handling code
to the end of this function implementation by adding jump targets?

Regards,
Markus