From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f193.google.com (mail-qk0-f193.google.com [209.85.220.193]) by dpdk.org (Postfix) with ESMTP id 8F5461B28A for ; Sun, 5 Nov 2017 18:24:59 +0100 (CET) Received: by mail-qk0-f193.google.com with SMTP id o6so1473552qkh.3 for ; Sun, 05 Nov 2017 09:24:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=m8G6PpoYgk8I1jrkGMDKCKY3ITfOvhJroRWIi3dAEJU=; b=o5F9qqQafV7QPqi+EdU/sA9QYcjuooaUdKeJh9fiG1ZT7T08IWxX1Jh1COSmxJXmSQ QFtOzdAGGD+GfEei8wSottTPPQV5uVVBaIAf1TlU2i9phMSeYN+B5Y9uHhG1uM7XTSTA XNYsC3uR/DBFtIqTScgUJzQBqQye4Mk+q4iHavNsxBSRqKx4aQnT31e3tVkMI4U9YIyA c/z+bVdij1aMHZseFP8qgFj7SFrwgNoYh/MrovsShABkNl1abdI1TUG/jWyISWbEvfRt //+QsGRSXOcQDoOMPOuJqCXnGm72TX7WkuNib8c61MUVmydiKpaEFz+QbyOh8mFfA+Yo SYPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=m8G6PpoYgk8I1jrkGMDKCKY3ITfOvhJroRWIi3dAEJU=; b=GKm35M0Z1gKCmonsem53mK2lPBJnReuAeTqBeaQa/Bm9glLnuF2wBWFjUOBsIKNzyV mrrrbHwrhsjzP1dRGBHzOJXO5bxgsS4ode+DmkcZGB2b9zJ07DjHw5TXmxn19stLlkuP yOYAUzA2gWAdn9pNkDw+jDJpOsHPWBs9tY2bnX/2nOKFCA+MDqTvV2Vr0N7FpEap7Wlg 4J1Xe3gXUGW1oVEBV2bV8Wvlix+eW4Cx3gLRcOHe19Wzygi1fefWic9Dt1KS8hnSKJkS ObOSA6fSka1AKU7tAUx5ZvXsRwlFQqJabpST6jmhZZ/R9itELT0bqT83PbgSJnG9+zTB 4cBg== X-Gm-Message-State: AMCzsaX9ILHzjr2mXX6I4CbFmdixt9VSOA0OOB90pWxG5J8nZJTATXr+ fNMhgHjGrlaGc/SzbszG2B0= X-Google-Smtp-Source: ABhQp+Qde7iVfV71OFHklSG9+p60LVrjMykDB2djGdgYQVlPTR9tLQo5wQTBwXoE5F+BmQ+BG9sUyw== X-Received: by 10.55.160.18 with SMTP id j18mr18853112qke.327.1509902698806; Sun, 05 Nov 2017 09:24:58 -0800 (PST) Received: from iceblazer.shadowybug.net (pool-71-244-160-213.bltmmd.fios.verizon.net. [71.244.160.213]) by smtp.gmail.com with ESMTPSA id n44sm7334621qtb.41.2017.11.05.09.24.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Nov 2017 09:24:57 -0800 (PST) From: Stefan Baranoff To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Stefan Baranoff Date: Sun, 5 Nov 2017 12:24:45 -0500 Message-Id: <20171105172445.9401-1-sbaranoff@gmail.com> X-Mailer: git-send-email 2.14.1 Subject: [dpdk-dev] [PATCH] net/pcap: fix memory leak from missing pcap_close X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Nov 2017 17:24:59 -0000 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 --- 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