]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
fix off-by-one error in pci_piix3_xen_ide_unplug
authorJames Harper <james@ejbdigital.com.au>
Thu, 30 Oct 2014 10:08:28 +0000 (10:08 +0000)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Fri, 31 Jul 2015 16:53:21 +0000 (16:53 +0000)
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-commmit-id: ab44b867744b2246302da73a8ef0ed26876f2981

Signed-off-by: James Harper <james.harper@ejbdigital.com.au>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
hw/ide/piix.c

index 9431badadfb4c29a537df274e865dbc7110c4f65..34b47a0b12f1c2b32b6e8ccf9d3b441caddb888a 100644 (file)
@@ -171,12 +171,12 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)
     PCIDevice *pci_dev;
     PCIIDEState *pci_ide;
     DriveInfo *di;
-    int i = 0;
+    int i;
 
     pci_dev = DO_UPCAST(PCIDevice, qdev, dev);
     pci_ide = DO_UPCAST(PCIIDEState, dev, pci_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);