diff options
author | nickcooper-zhangtonghao <nic@opencloud.tech> | 2017-02-09 03:25:41 -0800 |
---|---|---|
committer | Daniele Di Proietto <diproiettod@vmware.com> | 2017-02-10 14:47:01 -0800 |
commit | 6c4f08e23f5ec5c97508b42ae8440a8dadc520da (patch) | |
tree | ecb4ab20e03d1b3dfe2ad280e485f22273a29162 /lib | |
parent | d46b603797c6fa8ab979e3de4ead73e50a37e7ec (diff) | |
download | openvswitch-6c4f08e23f5ec5c97508b42ae8440a8dadc520da.tar.gz |
dpdk: Fixes memory leak in dpdk_init__().
If users configure the 'vhost-sock-dir' for dpdk, the memory
allocated by xstrdup(ovs_rundir()) is not freed. This patch
allows the process_vhost_flags to xstrdup() for val or
default_val according to configuration and the caller must
free new_val when it is no longer needed.
Fixes: 01961bbdd34a ("dpdk: New module with some code from netdev-dpdk.")
CC: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: nickcooper-zhangtonghao <nic@opencloud.tech>
Reviewed-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dpdk.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/dpdk.c b/lib/dpdk.c index 9ae249141..c1626e224 100644 --- a/lib/dpdk.c +++ b/lib/dpdk.c @@ -39,7 +39,7 @@ VLOG_DEFINE_THIS_MODULE(dpdk); static char *vhost_sock_dir = NULL; /* Location of vhost-user sockets */ static int -process_vhost_flags(char *flag, char *default_val, int size, +process_vhost_flags(char *flag, const char *default_val, int size, const struct smap *ovs_other_config, char **new_val) { @@ -57,7 +57,7 @@ process_vhost_flags(char *flag, char *default_val, int size, VLOG_INFO("User-provided %s in use: %s", flag, *new_val); } else { VLOG_INFO("No %s provided - defaulting to %s", flag, default_val); - *new_val = default_val; + *new_val = xstrdup(default_val); } return changed; @@ -273,7 +273,7 @@ dpdk_init__(const struct smap *ovs_other_config) cpu_set_t cpuset; char *sock_dir_subcomponent; - if (process_vhost_flags("vhost-sock-dir", xstrdup(ovs_rundir()), + if (process_vhost_flags("vhost-sock-dir", ovs_rundir(), NAME_MAX, ovs_other_config, &sock_dir_subcomponent)) { struct stat s; |