Re: [PATCH net v2 1/2] octeontx2-pf: fix netdev memory leak in rvu_rep_create()

From: Markus Elfring
Date: Wed Dec 18 2024 - 12:39:19 EST


> When rvu_rep_devlink_port_register() fails, free_netdev(ndev) for this
> incomplete iteration before going to "exit:" label.



> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
> @@ -680,8 +680,10 @@ int rvu_rep_create(struct otx2_nic *priv, struct netlink_ext_ack *extack)
> ndev->features |= ndev->hw_features;
> eth_hw_addr_random(ndev);
> err = rvu_rep_devlink_port_register(rep);
> - if (err)
> + if (err) {
> + free_netdev(ndev);
> goto exit;
> + }
>
> SET_NETDEV_DEVLINK_PORT(ndev, &rep->dl_port);


I suggest to add another jump target instead so that a bit of exception handling
can be better reused at the end of this function implementation.

Regards,
Markus