DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/pcap: fix memory leak from missing pcap_close
@ 2017-11-05 17:24 Stefan Baranoff
  2017-11-06 19:52 ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Baranoff @ 2017-11-05 17:24 UTC (permalink / raw)
  To: ferruh.yigit; +Cc: dev, Stefan Baranoff

In open_single_tx_pcap there is a call to pcap_open_dead which calls
malloc to create and return a pcap_t. That object is never freed in
this case. Other places it is freed by passing it back similar to the
way the pcap_dumper_t is in this case.

The pcap_t is only used to create the pcap_dumper_t and is never used
again so freeing it here is safe and much simpler than trying to pass
it back to be freed in eth_dev_stop along with the other
pcap_t/pcap_dumper_t objects.

Signed-off-by: Stefan Baranoff <sbaranoff@gmail.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 3205df89f..3024c1e03 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -411,11 +411,13 @@ open_single_tx_pcap(const char *pcap_filename, pcap_dumper_t **dumper)
 	/* The dumper is created using the previous pcap_t reference */
 	*dumper = pcap_dump_open(tx_pcap, pcap_filename);
 	if (*dumper == NULL) {
+		pcap_close(tx_pcap);
 		RTE_LOG(ERR, PMD, "Couldn't open %s for writing.\n",
 			pcap_filename);
 		return -1;
 	}
 
+	pcap_close(tx_pcap);
 	return 0;
 }
 
-- 
2.14.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/pcap: fix memory leak from missing pcap_close
  2017-11-05 17:24 [dpdk-dev] [PATCH] net/pcap: fix memory leak from missing pcap_close Stefan Baranoff
@ 2017-11-06 19:52 ` Ferruh Yigit
  2017-11-07  8:53   ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Ferruh Yigit @ 2017-11-06 19:52 UTC (permalink / raw)
  To: Stefan Baranoff; +Cc: dev

On 11/5/2017 9:24 AM, Stefan Baranoff wrote:
> In open_single_tx_pcap there is a call to pcap_open_dead which calls
> malloc to create and return a pcap_t. That object is never freed in
> this case. Other places it is freed by passing it back similar to the
> way the pcap_dumper_t is in this case.
> 
> The pcap_t is only used to create the pcap_dumper_t and is never used
> again so freeing it here is safe and much simpler than trying to pass
> it back to be freed in eth_dev_stop along with the other
> pcap_t/pcap_dumper_t objects.
> 
> Signed-off-by: Stefan Baranoff <sbaranoff@gmail.com>

net/pcap: fix memory leak in dumper open

Fixes: 4c173302c307 ("pcap: add new driver")
Cc: stable@dpdk.org

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/pcap: fix memory leak from missing pcap_close
  2017-11-06 19:52 ` Ferruh Yigit
@ 2017-11-07  8:53   ` Ferruh Yigit
  0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2017-11-07  8:53 UTC (permalink / raw)
  To: Stefan Baranoff; +Cc: dev

On 11/6/2017 11:52 AM, Ferruh Yigit wrote:
> On 11/5/2017 9:24 AM, Stefan Baranoff wrote:
>> In open_single_tx_pcap there is a call to pcap_open_dead which calls
>> malloc to create and return a pcap_t. That object is never freed in
>> this case. Other places it is freed by passing it back similar to the
>> way the pcap_dumper_t is in this case.
>>
>> The pcap_t is only used to create the pcap_dumper_t and is never used
>> again so freeing it here is safe and much simpler than trying to pass
>> it back to be freed in eth_dev_stop along with the other
>> pcap_t/pcap_dumper_t objects.
>>
>> Signed-off-by: Stefan Baranoff <sbaranoff@gmail.com>
> 
> net/pcap: fix memory leak in dumper open
> 
> Fixes: 4c173302c307 ("pcap: add new driver")
> Cc: stable@dpdk.org
> 
> Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-07  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-05 17:24 [dpdk-dev] [PATCH] net/pcap: fix memory leak from missing pcap_close Stefan Baranoff
2017-11-06 19:52 ` Ferruh Yigit
2017-11-07  8:53   ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).