[PATCH] qemu: avoid dereferencing a NULL pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Alex Jia <ajia@xxxxxxxxxx>

* src/qemu/qemu_hostdev.c: function 'pciDeviceListFind' probably explicitly
  returns null, however, the function 'pciDeviceSetUsedBy' directly uses it
  without any judgement.

Signed-off-by: Alex Jia <ajia@xxxxxxxxxx>
---
 src/qemu/qemu_hostdev.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index c65f6f5..4e148b0 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -227,9 +227,8 @@ int qemuPrepareHostdevPCIDevices(struct qemud_driver *driver,
         pciDevice *dev, *activeDev;
 
         dev = pciDeviceListGet(pcidevs, i);
-        activeDev = pciDeviceListFind(driver->activePciHostdevs, dev);
-
-        pciDeviceSetUsedBy(activeDev, name);
+        if ((activeDev = pciDeviceListFind(driver->activePciHostdevs, dev)))
+            pciDeviceSetUsedBy(activeDev, name);
     }
 
     /* Loop 6: Now steal all the devices from pcidevs */
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]