If adding an interface to the capture file failed, the error path
called rte_pcapng_close(), which closes the file descriptor,
and then closed the same descriptor again.

Only close the descriptor directly if rte_pcapng_fdopen() failed.

Fixes: df5908c98abc ("graph: fix pcapng file support")
Cc: [email protected]

Signed-off-by: Stephen Hemminger <[email protected]>
---
 lib/graph/graph_pcap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/graph/graph_pcap.c b/lib/graph/graph_pcap.c
index 78859ec2d4..07678d967d 100644
--- a/lib/graph/graph_pcap.c
+++ b/lib/graph/graph_pcap.c
@@ -128,11 +128,13 @@ graph_pcap_file_open(const char *filename)
 done:
        return 0;
 error:
+       /* once rte_pcapng_fdopen() succeeds, the fd is closed by 
rte_pcapng_close() */
        if (pcapng_fd != NULL) {
                rte_pcapng_close(pcapng_fd);
                pcapng_fd = NULL;
+       } else {
+               close(fd);
        }
-       close(fd);
        return -1;
 }
 
-- 
2.53.0

Reply via email to