[libvirt] [PATCH] fix memory leak in qemuMonitorJSONAttachCharDevCommand

Yi Wang posted 1 patch 6 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1497247555-4316-1-git-send-email-wang.yi59@zte.com.cn
src/qemu/qemu_monitor_json.c | 1 +
1 file changed, 1 insertion(+)
[libvirt] [PATCH] fix memory leak in qemuMonitorJSONAttachCharDevCommand
Posted by Yi Wang 6 years, 9 months ago
The @tlsalias allocated in qemuAliasTLSObjFromSrcAlias may lost
 when append string to json.

Signed-off-by: Xi Xu <xu.xi8@zte.com.cn>
---
 src/qemu/qemu_monitor_json.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index f208dd0..773de0f 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6487,6 +6487,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
 
             if (virJSONValueObjectAppendString(data, "tls-creds", tlsalias) < 0)
                 goto error;
+            VIR_FREE(tlsalias);
         }
         break;
 
-- 
1.8.3.1


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] fix memory leak in qemuMonitorJSONAttachCharDevCommand
Posted by Erik Skultety 6 years, 9 months ago
On Mon, Jun 12, 2017 at 02:05:55AM -0400, Yi Wang wrote:
> The @tlsalias allocated in qemuAliasTLSObjFromSrcAlias may lost
>  when append string to json.
>
> Signed-off-by: Xi Xu <xu.xi8@zte.com.cn>
> ---
>  src/qemu/qemu_monitor_json.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index f208dd0..773de0f 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -6487,6 +6487,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
>
>              if (virJSONValueObjectAppendString(data, "tls-creds", tlsalias) < 0)
>                  goto error;
> +            VIR_FREE(tlsalias);
>          }
>          break;

Although correct, we needed only 1 place where all the cleanup takes place, see
the patch I merged upstream [1]

Thanks,
Erik

[1] http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=bb12db16b41032cf7c6001a4d0e7ee20720c93a0

>
> --
> 1.8.3.1
>
>
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list