Message ID | 1486639541-15336-1-git-send-email-nic@opencloud.tech |
---|---|
State | Accepted |
Headers | show |
nickcooper-zhangtonghao <nic@opencloud.tech> writes: > 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> > --- Great catch! Reviewed-by: Aaron Conole <aconole@redhat.com>
On 10/02/2017 08:46, "Aaron Conole" <aconole@redhat.com> wrote: >nickcooper-zhangtonghao <nic@opencloud.tech> writes: > >> 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> >> --- > >Great catch! > >Reviewed-by: Aaron Conole <aconole@redhat.com> Oops, thanks for the fix! pushed to master and branch-2.7
diff --git a/lib/dpdk.c b/lib/dpdk.c index 9ae2491..c1626e2 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;
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> --- lib/dpdk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)