From 1c1789ccb329df1cfd4d299b8c9898bd2fd2f38b Mon Sep 17 00:00:00 2001 From: Rahul Lakkireddy Date: Fri, 12 Feb 2016 17:15:30 +0530 Subject: [PATCH] cxgbe: fix memory leak after initialization failure Add missing code to free adapter when the device initialization fails. Fixes: 8318984927ff ("cxgbe: add pmd skeleton") Reported-by: Seth Arnold Signed-off-by: Rahul Lakkireddy Signed-off-by: Kumar Sanghvi --- drivers/net/cxgbe/cxgbe_ethdev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index 97ef152e46..1a4293d296 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -838,11 +838,16 @@ static int eth_cxgbe_dev_init(struct rte_eth_dev *eth_dev) pi->adapter = adapter; err = cxgbe_probe(adapter); - if (err) + if (err) { dev_err(adapter, "%s: cxgbe probe failed with err %d\n", __func__, err); + goto out_free_adapter; + } + + return 0; out_free_adapter: + rte_free(adapter); return err; } -- 2.20.1