From: Declan Doherty <declan.doherty@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] bond: fix for kvlist memory leak on rte_kvargs_process failure identified by klockwork scan
Date: Fri, 13 Feb 2015 10:27:26 +0000 [thread overview]
Message-ID: <1423823246-32211-1-git-send-email-declan.doherty@intel.com> (raw)
Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
lib/librte_pmd_bond/rte_eth_bond_pmd.c | 49 ++++++++++++++++++----------------
1 file changed, 26 insertions(+), 23 deletions(-)
diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
index 09b0f30..a75b163 100644
--- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
+++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
@@ -1622,32 +1622,32 @@ bond_init(const char *name, const char *params)
/* Parse link bonding mode */
if (rte_kvargs_count(kvlist, PMD_BOND_MODE_KVARG) == 1) {
if (rte_kvargs_process(kvlist, PMD_BOND_MODE_KVARG,
- &bond_ethdev_parse_slave_mode_kvarg, &bonding_mode) != 0) {
- RTE_LOG(ERR, EAL, "Invalid mode for bonded device %s\n", name);
- return -1;
+ &bond_ethdev_parse_slave_mode_kvarg,
+ &bonding_mode) != 0) {
+ RTE_LOG(ERR, EAL, "Invalid mode for bonded device %s\n",
+ name);
+ goto parse_error;
}
} else {
- RTE_LOG(ERR, EAL,
- "Mode must be specified only once for bonded device %s\n",
- name);
- return -1;
+ RTE_LOG(ERR, EAL, "Mode must be specified only once for bonded "
+ "device %s\n", name);
+ goto parse_error;
}
/* Parse socket id to create bonding device on */
arg_count = rte_kvargs_count(kvlist, PMD_BOND_SOCKET_ID_KVARG);
if (arg_count == 1) {
if (rte_kvargs_process(kvlist, PMD_BOND_SOCKET_ID_KVARG,
- &bond_ethdev_parse_socket_id_kvarg, &socket_id) != 0) {
- RTE_LOG(ERR, EAL,
- "Invalid socket Id specified for bonded device %s\n",
- name);
- return -1;
+ &bond_ethdev_parse_socket_id_kvarg, &socket_id)
+ != 0) {
+ RTE_LOG(ERR, EAL, "Invalid socket Id specified for "
+ "bonded device %s\n", name);
+ goto parse_error;
}
} else if (arg_count > 1) {
- RTE_LOG(ERR, EAL,
- "Socket Id can be specified only once for bonded device %s\n",
- name);
- return -1;
+ RTE_LOG(ERR, EAL, "Socket Id can be specified only once for "
+ "bonded device %s\n", name);
+ goto parse_error;
} else {
socket_id = rte_socket_id();
}
@@ -1655,18 +1655,21 @@ bond_init(const char *name, const char *params)
/* Create link bonding eth device */
port_id = rte_eth_bond_create(name, bonding_mode, socket_id);
if (port_id < 0) {
- RTE_LOG(ERR, EAL,
- "Failed to create socket %s in mode %u on socket %u.\n",
- name, bonding_mode, socket_id);
- return -1;
+ RTE_LOG(ERR, EAL, "Failed to create socket %s in mode %u on "
+ "socket %u.\n", name, bonding_mode, socket_id);
+ goto parse_error;
}
internals = rte_eth_devices[port_id].data->dev_private;
internals->kvlist = kvlist;
- RTE_LOG(INFO, EAL,
- "Create bonded device %s on port %d in mode %u on socket %u.\n",
- name, port_id, bonding_mode, socket_id);
+ RTE_LOG(INFO, EAL, "Create bonded device %s on port %d in mode %u on "
+ "socket %u.\n", name, port_id, bonding_mode, socket_id);
return 0;
+
+parse_error:
+ rte_kvargs_free(kvlist);
+
+ return -1;
}
/* this part will resolve the slave portids after all the other pdev and vdev
--
1.9.3
next reply other threads:[~2015-02-13 10:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-13 10:27 Declan Doherty [this message]
2015-02-13 10:37 ` Olivier MATZ
2015-02-18 17:13 ` Thomas Monjalon
2015-02-13 10:43 ` De Lara Guarch, Pablo
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=1423823246-32211-1-git-send-email-declan.doherty@intel.com \
--to=declan.doherty@intel.com \
--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).