mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
pci: fix null pointer dereference
Clang detected a null-pointer dereference regression, introduced
in commit 4e8969eb
. Without this patch, a device with
unbind_from_stub set to false would eventually try to call
virFileExists on uncomputed drvdir.
* src/util/pci.c (pciUnbindDeviceFromStub): Ensure drvdir is set
before use.
This commit is contained in:
parent
4d080ee403
commit
1164e1a2da
@ -879,15 +879,16 @@ pciUnbindDeviceFromStub(pciDevice *dev, const char *driver)
|
||||
char *drvdir = NULL;
|
||||
char *path = NULL;
|
||||
|
||||
if (pciDriverDir(&drvdir, driver) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!dev->unbind_from_stub)
|
||||
goto remove_slot;
|
||||
|
||||
/* If the device is bound to stub, unbind it.
|
||||
*/
|
||||
if (pciDriverDir(&drvdir, driver) < 0 ||
|
||||
pciDeviceFile(&path, dev->name, "driver") < 0) {
|
||||
if (pciDeviceFile(&path, dev->name, "driver") < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virFileExists(drvdir) && virFileLinkPointsTo(path, drvdir)) {
|
||||
if (pciDriverFile(&path, driver, "unbind") < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user