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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux