[libvirt] [PATCH] cpu_x86: Fix memory leak in virCPUx86Translate

Jiri Denemark posted 1 patch 7 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/54771f831b2b8178e56f1f4415a93e955856848b.1486629697.git.jdenemar@redhat.com
src/cpu/cpu_x86.c | 4 ----
1 file changed, 4 deletions(-)
[libvirt] [PATCH] cpu_x86: Fix memory leak in virCPUx86Translate
Posted by Jiri Denemark 7 years, 1 month ago
virCPUDefStealModel is called with keepVendor == true which means the
cpu structure will keep its original vendor/vendor_id values. Thus it
makes no sense to copy them to the translated definition as they won't
be used there anyway. Except that the translated->vendor pointer might
get lost in x86Decode.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/cpu/cpu_x86.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 23a519ec0..9e22f896e 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2709,10 +2709,6 @@ virCPUx86Translate(virCPUDefPtr cpu,
     if (!(translated = virCPUDefCopyWithoutModel(cpu)))
         goto cleanup;
 
-    if (VIR_STRDUP(translated->vendor, cpu->vendor) < 0 ||
-        VIR_STRDUP(translated->vendor_id, cpu->vendor_id) < 0)
-        goto cleanup;
-
     if (x86Decode(translated, &model->data, models, nmodels, NULL, 0) < 0)
         goto cleanup;
 
-- 
2.11.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] cpu_x86: Fix memory leak in virCPUx86Translate
Posted by Peter Krempa 7 years, 1 month ago
On Thu, Feb 09, 2017 at 09:41:37 +0100, Jiri Denemark wrote:
> virCPUDefStealModel is called with keepVendor == true which means the
> cpu structure will keep its original vendor/vendor_id values. Thus it
> makes no sense to copy them to the translated definition as they won't
> be used there anyway. Except that the translated->vendor pointer might
> get lost in x86Decode.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/cpu/cpu_x86.c | 4 ----
>  1 file changed, 4 deletions(-)

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