[libvirt] [PATCHv2 12/12] qemu: fix infinite loop in OOM error path
Daniel P. Berrange
berrange at redhat.com
Tue Jun 25 10:47:30 UTC 2013
On Mon, Jun 24, 2013 at 11:05:38PM -0400, Laine Stump wrote:
> A loop in qemuPrepareHostdevPCIDevices() intended to cycle through all
> the objects on the list pcidevs was doing "while (listcount > 0)", but
> nothing in the body of the loop was reducing the size of the list - it
> was instead removing items from a *different* list. It has now been
> safely changed to a for() loop.
> ---
> src/qemu/qemu_hostdev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
> index 09ac6ad..404939e 100644
> --- a/src/qemu/qemu_hostdev.c
> +++ b/src/qemu/qemu_hostdev.c
> @@ -638,8 +638,8 @@ inactivedevs:
> /* Only steal all the devices from driver->activePciHostdevs. We will
> * free them in virObjectUnref().
> */
> - while (virPCIDeviceListCount(pcidevs) > 0) {
> - virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, 0);
> + for (i = 0; i < virPCIDeviceListCount(pcidevs); i++) {
> + virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
> virPCIDeviceListSteal(driver->activePciHostdevs, dev);
> }
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list