[libvirt] [PATCH] qemu: check the validity of a pointer
Peter Krempa
pkrempa at redhat.com
Mon Feb 16 18:20:35 UTC 2015
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.gatto at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150216/283b4ad1/attachment-0001.sig>
More information about the libvir-list
mailing list