diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2011-05-15 19:27:34 +0300 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2011-05-16 14:23:45 +0300 |
commit | 69c8944f17cb6c084567a16c080cfa7bc780e668 (patch) | |
tree | b1716ac16dc07d04f3dce3c92148bc06cb5d6c82 /hw/ide | |
parent | 5300f1a5487f67f0bde8ee1081b799108668cb1d (diff) | |
download | qemu-69c8944f17cb6c084567a16c080cfa7bc780e668.zip qemu-69c8944f17cb6c084567a16c080cfa7bc780e668.tar.gz qemu-69c8944f17cb6c084567a16c080cfa7bc780e668.tar.bz2 |
ich/ahci: fix uninitialized memory use
The commit 667bb59d2358daeef179583c944becba3f1f9680
uses d->ahci.mem before it is initialized by
ahci_init(). Fix this by calling ahci_init() first thing
so that it's safe to use all fields in the ahci state struct.
Reported-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
Reported-by: Jan Kiszka <jan.kiszka@web.de>
Tested-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/ide')
-rw-r--r-- | hw/ide/ich.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/ide/ich.c b/hw/ide/ich.c index e44339b..5ce0a88 100644 --- a/hw/ide/ich.c +++ b/hw/ide/ich.c @@ -77,6 +77,8 @@ static int pci_ich9_ahci_init(PCIDevice *dev) struct AHCIPCIState *d; d = DO_UPCAST(struct AHCIPCIState, card, dev); + ahci_init(&d->ahci, &dev->qdev, 6); + pci_config_set_vendor_id(d->card.config, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(d->card.config, PCI_DEVICE_ID_INTEL_82801IR); @@ -97,8 +99,6 @@ static int pci_ich9_ahci_init(PCIDevice *dev) pci_register_bar_simple(&d->card, 5, 0x1000, 0, d->ahci.mem); msi_init(dev, 0x50, 1, true, false); - - ahci_init(&d->ahci, &dev->qdev, 6); d->ahci.irq = d->card.irq[0]; return 0; |