[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] pci: add checking whether the device is realized be
From: |
SeokYeon Hwang |
Subject: |
[Qemu-devel] [PATCH] pci: add checking whether the device is realized before unlinking the capability |
Date: |
Wed, 25 Jun 2014 18:59:08 +0900 |
In case of the unrealized "pdev", memory can be illegally accessed and
corrupted.
Refer to device_unparent() in the commit
5c21ce77d7e5643089ceec556c0408445d017f32.
Change-Id: Iacb195a092c86d4c677ad0404582af104b2251ae
Signed-off-by: SeokYeon Hwang <address@hidden>
---
hw/pci/pci.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 49eca95..bb7f0c5 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2056,7 +2056,12 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
/* Unlink capability from the pci config space. */
void pci_del_capability(PCIDevice *pdev, uint8_t cap_id, uint8_t size)
{
- uint8_t prev, offset = pci_find_capability_list(pdev, cap_id, &prev);
+ uint8_t prev, offset;
+ /* Check whether the device is realized or not */
+ if (!pdev->qdev.realized) {
+ return;
+ }
+ offset = pci_find_capability_list(pdev, cap_id, &prev);
if (!offset)
return;
pdev->config[prev] = pdev->config[offset + PCI_CAP_LIST_NEXT];
--
1.9.1
- [Qemu-devel] [PATCH] pci: add checking whether the device is realized before unlinking the capability,
SeokYeon Hwang <=