From da2e633ec99da897f51f388217f070c53aea6674 Mon Sep 17 00:00:00 2001 From: James Harper Date: Thu, 30 Oct 2014 10:08:28 +0000 Subject: [PATCH] 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 --- hw/ide/piix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 08cbbe203..3dbfc12a7 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -169,12 +169,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); -- 2.39.5