From: Tetsuya Mukawa Date: Tue, 17 Mar 2015 04:12:41 +0000 (+0900) Subject: null: fix memory leak of kvargs X-Git-Tag: spdx-start~9415 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=6e225d6a21c10ea3a83fd6fc5a2bc2d7f27bf841;p=dpdk.git null: fix memory leak of kvargs 'struct rte_kvargs' is allocated in rte_kvargs_parse(), and should be freed with rte_kvargs_free(). Reported-by: John Mcnamara Signed-off-by: Tetsuya Mukawa Acked-by: Neil Horman --- diff --git a/lib/librte_pmd_null/rte_eth_null.c b/lib/librte_pmd_null/rte_eth_null.c index f49d6864ae..8fe1a2d554 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