[libvirt] [PATCH] fix error when parsing ppc64 models on x86 host
Eric Blake
eblake at redhat.com
Fri Dec 9 15:55:37 UTC 2011
On 12/09/2011 07:27 AM, Stefan Berger wrote:
> When parsing ppc64 models on an x86 host an out-of-memory error message
> is displayed due
> to it checking for retcpus being NULL. Fix this by removing the check
> whether retcpus is NULL
> since we will realloc into this variable.
> Also in the X86 model parser display the OOM error at the location where
> it happens.
>
> @@ -493,11 +497,6 @@ qemuCapsParsePPCModels(const char *outpu
> const char **cpus = NULL;
> int i;
>
> - if (!retcpus) {
> - VIR_DEBUG("No retcpus specified");
> - return -1;
> - }
This hunk looks okay, but your patch is incomplete; later on, we have:
if (retcount)
*retcount = count;
if (retcpus)
*retcpus = cpus;
return 0;
error:
if (cpus) {
for (i = 0; i < count; i++)
VIR_FREE(cpus[i]);
}
VIR_FREE(cpus);
return -1;
What this really needs to be is:
if (retcpus) {
*retcpus = cpus;
cpus = NULL;
}
ret = 0;
cleanup:
if (cpus) { ... }
VIR_FREE(cpus);
return ret;
so that we don't leak cpus when retcpus is NULL. Looking forward to v2.
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111209/9a33bd88/attachment-0001.sig>
More information about the libvir-list
mailing list