net/pcap: fix memory leak

Message ID 20190130010854.27352-1-qi.z.zhang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/pcap: fix memory leak |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Qi Zhang Jan. 30, 2019, 1:08 a.m. UTC
  Fix potential memory leak due to kvlist not be freed.

Fixes: 0d0dd2d9d8ff ("net/pcap: enable data path for secondary process")
Cc: stable@dpdk.org

Reported-by: Gage Eads <gage.eads@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Ferruh Yigit Jan. 30, 2019, 11:30 a.m. UTC | #1
On 1/30/2019 1:08 AM, Qi Zhang wrote:
> Fix potential memory leak due to kvlist not be freed.
> 
> Fixes: 0d0dd2d9d8ff ("net/pcap: enable data path for secondary process")
> Cc: stable@dpdk.org
> 
> Reported-by: Gage Eads <gage.eads@intel.com>
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
  
Ferruh Yigit Feb. 7, 2019, 12:29 p.m. UTC | #2
On 1/30/2019 11:30 AM, Ferruh Yigit wrote:
> On 1/30/2019 1:08 AM, Qi Zhang wrote:
>> Fix potential memory leak due to kvlist not be freed.
>>
>> Fixes: 0d0dd2d9d8ff ("net/pcap: enable data path for secondary process")
>> Cc: stable@dpdk.org
>>
>> Reported-by: Gage Eads <gage.eads@intel.com>
>> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 9fd932772..65bbd7e2f 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -1258,7 +1258,8 @@  pmd_pcap_probe(struct rte_vdev_device *dev)
 		if (pp == NULL) {
 			PMD_LOG(ERR,
 				"Failed to allocate memory for process private");
-			return -1;
+			ret = -1;
+			goto free_kvlist;
 		}
 
 		eth_dev->dev_ops = &ops;
@@ -1281,7 +1282,7 @@  pmd_pcap_probe(struct rte_vdev_device *dev)
 			eth_dev->tx_pkt_burst = eth_pcap_tx;
 
 		rte_eth_dev_probing_finish(eth_dev);
-		return 0;
+		goto free_kvlist;
 	}
 
 	ret = eth_from_pcaps(dev, &pcaps, pcaps.num_of_queue, &dumpers,