From: James Harper Date: Thu, 30 Oct 2014 10:08:28 +0000 (+0000) Subject: fix off-by-one error in pci_piix3_xen_ide_unplug X-Git-Tag: qemu-xen-4.5.2~12 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=272a614387ac25f2727a7f5c292111975e33b2fb;p=qemu-upstream-4.5-testing.git fix off-by-one error in pci_piix3_xen_ide_unplug Fix off-by-one error when unplugging disks, which would otherwise leave the last ATA disk plugged, with obvious consequences. Also rewrite loop to be more readable. upstream-commit-id: d4f9e806c20607cafe7bb0d9eba14ccb160390a1 Signed-off-by: James Harper Signed-off-by: Stefano Stabellini --- diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 40757eb00..d70b73d57 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -171,11 +171,11 @@ int pci_piix3_xen_ide_unplug(DeviceState *dev) { PCIIDEState *pci_ide; DriveInfo *di; - int i = 0; + int i; pci_ide = PCI_IDE(dev); - for (; i < 3; i++) { + for (i = 0; i < 4; i++) { di = drive_get_by_index(IF_IDE, i); if (di != NULL && !di->media_cd) { DeviceState *ds = bdrv_get_attached_dev(di->bdrv);