cxgbe: fix memory leak after initialization failure
authorRahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Fri, 12 Feb 2016 11:45:30 +0000 (17:15 +0530)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 16 Mar 2016 15:54:13 +0000 (16:54 +0100)
Add missing code to free adapter when the device initialization fails.

Fixes: 8318984927ff ("cxgbe: add pmd skeleton")

Reported-by: Seth Arnold <seth.arnold@canonical.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Signed-off-by: Kumar Sanghvi <kumaras@chelsio.com>
drivers/net/cxgbe/cxgbe_ethdev.c

index 97ef152..1a4293d 100644 (file)
@@ -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;
 }