From: Tetsuya Mukawa <mukawa@igel.co.jp>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2] pcap, null: Fix memory leaks of 'struct rte_kvargs'
Date: Tue, 17 Mar 2015 13:12:41 +0900 [thread overview]
Message-ID: <1426565561-23051-1-git-send-email-mukawa@igel.co.jp> (raw)
In-Reply-To: <1426477376-13385-1-git-send-email-mukawa@igel.co.jp>
'struct rte_kvargs' is allocated in rte_kvargs_parse(), and should be
freed with rte_kvargs_free().
This patch fixes memory leaks of 'struct rte_kvargs' in below PMDs.
- pcap PMD
- null PMD
Reported-by: Mcnamara, John <john.mcnamara@intel.com>
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
lib/librte_pmd_null/rte_eth_null.c | 13 +++++++++----
lib/librte_pmd_pcap/rte_eth_pcap.c | 18 +++++++++++-------
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/lib/librte_pmd_null/rte_eth_null.c b/lib/librte_pmd_null/rte_eth_null.c
index f49d686..8fe1a2d 100644
--- a/lib/librte_pmd_null/rte_eth_null.c
+++ b/lib/librte_pmd_null/rte_eth_null.c
@@ -506,7 +506,7 @@ rte_pmd_null_devinit(const char *name, const char *params)
unsigned numa_node;
unsigned packet_size = default_packet_size;
unsigned packet_copy = default_packet_copy;
- struct rte_kvargs *kvlist;
+ struct rte_kvargs *kvlist = NULL;
int ret;
if (name == NULL)
@@ -527,7 +527,7 @@ rte_pmd_null_devinit(const char *name, const char *params)
ETH_NULL_PACKET_SIZE_ARG,
&get_packet_size_arg, &packet_size);
if (ret < 0)
- return -1;
+ goto free_kvlist;
}
if (rte_kvargs_count(kvlist, ETH_NULL_PACKET_COPY_ARG) == 1) {
@@ -536,7 +536,7 @@ rte_pmd_null_devinit(const char *name, const char *params)
ETH_NULL_PACKET_COPY_ARG,
&get_packet_copy_arg, &packet_copy);
if (ret < 0)
- return -1;
+ goto free_kvlist;
}
}
@@ -544,7 +544,12 @@ rte_pmd_null_devinit(const char *name, const char *params)
"packet copy is %s\n", packet_size,
packet_copy ? "enabled" : "disabled");
- return eth_dev_null_create(name, numa_node, packet_size, packet_copy);
+ ret = eth_dev_null_create(name, numa_node, packet_size, packet_copy);
+
+free_kvlist:
+ if (kvlist)
+ rte_kvargs_free(kvlist);
+ return ret;
}
static int
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c b/lib/librte_pmd_pcap/rte_eth_pcap.c
index 5e94930..204ae68 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -888,12 +888,13 @@ rte_pmd_pcap_devinit(const char *name, const char *params)
ret = rte_kvargs_process(kvlist, ETH_PCAP_IFACE_ARG,
&open_rx_tx_iface, &pcaps);
if (ret < 0)
- return -1;
+ goto free_kvlist;
dumpers.pcaps[0] = pcaps.pcaps[0];
dumpers.names[0] = pcaps.names[0];
dumpers.types[0] = pcaps.types[0];
- return rte_eth_from_pcaps(name, &pcaps, 1, &dumpers, 1,
+ ret = rte_eth_from_pcaps(name, &pcaps, 1, &dumpers, 1,
numa_node, kvlist, 1);
+ goto free_kvlist;
}
/*
@@ -911,7 +912,7 @@ rte_pmd_pcap_devinit(const char *name, const char *params)
}
if (ret < 0)
- return -1;
+ goto free_kvlist;
/*
* We check whether we want to open a TX stream to a real NIC or a
@@ -930,15 +931,18 @@ rte_pmd_pcap_devinit(const char *name, const char *params)
}
if (ret < 0)
- return -1;
+ goto free_kvlist;
if (using_dumpers)
- return rte_eth_from_pcaps_n_dumpers(name, &pcaps, pcaps.num_of_rx,
+ ret = rte_eth_from_pcaps_n_dumpers(name, &pcaps, pcaps.num_of_rx,
&dumpers, dumpers.num_of_tx, numa_node, kvlist);
-
- return rte_eth_from_pcaps(name, &pcaps, pcaps.num_of_rx, &dumpers,
+ else
+ ret = rte_eth_from_pcaps(name, &pcaps, pcaps.num_of_rx, &dumpers,
dumpers.num_of_tx, numa_node, kvlist, 0);
+free_kvlist:
+ rte_kvargs_free(kvlist);
+ return ret;
}
static int
--
1.9.1
next prev parent reply other threads:[~2015-03-17 4:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-16 3:42 [dpdk-dev] [PATCH] pcap, af_packet, " Tetsuya Mukawa
2015-03-16 10:47 ` Neil Horman
2015-03-17 3:53 ` Tetsuya Mukawa
2015-03-16 11:07 ` Mcnamara, John
2015-03-17 3:54 ` Tetsuya Mukawa
2015-03-17 4:12 ` Tetsuya Mukawa [this message]
2015-03-17 21:58 ` [dpdk-dev] [PATCH v2] pcap, " Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1426565561-23051-1-git-send-email-mukawa@igel.co.jp \
--to=mukawa@igel.co.jp \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).