On Wed, Dec 18, 2024 at 06:38:25PM +0100, Markus Elfring wrote: > > 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. > When you're cleaning up from inside a loop, then the best practices is to clean up partial iterations before the goto and then clean up whole iterations in the unwind ladder. So this patch is better the way that Harshit his written it. regards, dan carpenter