net/pcap: fix memory leak from missing pcap_close
PATCH 1/1 net/pcap: fix memory leak from missing pcap_close
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.
--- drivers/net/pcap/rte_eth_pcap.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/pcap/rte_eth_pcap.c +2 -0
@@ -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 ; }
Signature · 1 line
2.14.1
Quoted 11 lines · Stefan Baranoff
In
open_single_tx_pcapthere is a call topcap_open_deadwhich calls malloc to create and return apcap_t. That object is never freed in this case. Other places it is freed by passing it back similar to the way thepcap_dumper_tis in this case.The
pcap_tis only used to create thepcap_dumper_tand is never used again so freeing it here is safe and much simpler than trying to pass it back to be freed ineth_dev_stopalong with the other pcap_t/pcap_dumper_t objects.Signed-off-by Stefan Baranoff <[email protected]>
net/pcap: fix memory leak in dumper open
Ferruh Yigit
AppliedQuoted 11 lines · Ferruh Yigit
Quoted 10 lines · Stefan Baranoff
In
open_single_tx_pcapthere is a call topcap_open_deadwhich calls malloc to create and return apcap_t. That object is never freed in this case. Other places it is freed by passing it back similar to the way thepcap_dumper_tis in this case.The
pcap_tis only used to create thepcap_dumper_tand is never used again so freeing it here is safe and much simpler than trying to pass it back to be freed ineth_dev_stopalong with the other pcap_t/pcap_dumper_t objects.
Quoted 8 lines
Quoted 1 line
Signed-off-by Stefan Baranoff <[email protected]>net/pcap: fix memory leak in dumper open
Fixes 4c173302c307 ("pcap: add new driver")Acked-by Ferruh Yigit <[email protected]>
Applied to dpdk-next-net/master, thanks.