On 12/31/2011 02:59 AM, ajia@xxxxxxxxxx wrote: > From: Alex Jia <ajia@xxxxxxxxxx> > > Detected by Coverity. Leaks introduced in commit 93ab585 and > commit e8d6b29. Let's fix this in two parts, to ease backporting (since one was pre-0.9.8 and the other only in 0.9.9-rc1). Part 1: > > Signed-off-by: Alex Jia <ajia@xxxxxxxxxx> > --- > src/qemu/qemu_driver.c | 6 +++--- > 1 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index fbaa824..6a1e7cc 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -6014,6 +6014,7 @@ static int qemuDomainSetBlkioParameters(virDomainPtr dom, > } > if (j != ndevices) { > ret = -1; > + VIR_FREE(devices); > continue; Good catch, but still a leak; this needs to call virBlkioDeviceWeightArrayClear to avoid a leak. I'm pushing this instead: From 8267aea5a6149c9fad399530fc0e8d7f406d22fd Mon Sep 17 00:00:00 2001 From: Eric Blake <eblake@xxxxxxxxxx> Date: Sat, 31 Dec 2011 16:32:35 -0700 Subject: [PATCH] qemu: fix blkio memory leak on failure Leak detected by Coverity, and introduced in commit 93ab585. Reported by Alex Jia. * src/qemu/qemu_driver.c (qemuDomainSetBlkioParameters): Free devices array on error. --- src/qemu/qemu_driver.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fbaa824..d89303e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6012,11 +6012,8 @@ static int qemuDomainSetBlkioParameters(virDomainPtr dom, break; } } - if (j != ndevices) { - ret = -1; - continue; - } - if (qemuDomainMergeDeviceWeights(&vm->def->blkio.devices, + if (j != ndevices || + qemuDomainMergeDeviceWeights(&vm->def->blkio.devices, &vm->def->blkio.ndevices, devices, ndevices) < 0) ret = -1; -- 1.7.7.4 -- Eric Blake eblake@xxxxxxxxxx +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list