From: Pankaj Bansal Date: Fri, 8 Feb 2019 08:46:11 +0000 (+0000) Subject: drivers: net: ldpaa_eth: fix resource leak X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=4b0880d66baa1b96c6293051a03af0ad1bee7cb0;p=project%2Fbcm63xx%2Fu-boot.git drivers: net: ldpaa_eth: fix resource leak if an error occurs in ldpaa_eth_init, need to free all resources before returning the error. Threfore, free net_dev before returning from ldpaa_eth_init. Signed-off-by: Pankaj Bansal Acked-by: Joe Hershberger --- diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c index 73b7ba29df..34253e3924 100644 --- a/drivers/net/ldpaa_eth/ldpaa_eth.c +++ b/drivers/net/ldpaa_eth/ldpaa_eth.c @@ -1074,6 +1074,7 @@ int ldpaa_eth_init(int dpmac_id, phy_interface_t enet_if) priv = (struct ldpaa_eth_priv *)malloc(sizeof(struct ldpaa_eth_priv)); if (!priv) { printf("ldpaa_eth_priv malloc() failed\n"); + free(net_dev); return -ENOMEM; } memset(priv, 0, sizeof(struct ldpaa_eth_priv));