Re: [libvirt] [PATCH] qemu: check the validity of a pointer

2015-02-16 Thread Peter Krempa
On Mon, Feb 16, 2015 at 21:17:17 +0100, Matthias Gatto wrote:
 In the current code if mem_mask is NULL there is a goto error, but
 we freeing it without knowing if mem_mask is NULL or not, therefor
 I've had a check.
 
 Signed-off-by: Matthias Gatto matthias.ga...@outscale.com
 ---
  src/qemu/qemu_cgroup.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
 index ca255c8..926726c 100644
 --- a/src/qemu/qemu_cgroup.c
 +++ b/src/qemu/qemu_cgroup.c
 @@ -810,7 +810,8 @@ qemuRestoreCgroupState(virDomainObjPtr vm)
  goto error;
  
   cleanup:
 -VIR_FREE(mem_mask);
 +if (mem_mask)
 +VIR_FREE(mem_mask);

NACK,

VIR_FREE actually checks if the pointer is NULL before freeing it.

The real problem is that 'mem_mask' is not initialized to NULL.

Peter


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] qemu: check the validity of a pointer

2015-02-16 Thread Matthias Gatto
In the current code if mem_mask is NULL there is a goto error, but
we freeing it without knowing if mem_mask is NULL or not, therefor
I've had a check.

Signed-off-by: Matthias Gatto matthias.ga...@outscale.com
---
 src/qemu/qemu_cgroup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index ca255c8..926726c 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -810,7 +810,8 @@ qemuRestoreCgroupState(virDomainObjPtr vm)
 goto error;
 
  cleanup:
-VIR_FREE(mem_mask);
+if (mem_mask)
+VIR_FREE(mem_mask);
 virBitmapFree(all_nodes);
 return;
 
-- 
1.8.3.1

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