static int
-virPCIDeviceBindToStub(virPCIDevicePtr dev,
- const char *stubDriverName)
+virPCIDeviceBindToStub(virPCIDevicePtr dev)
{
int result = -1;
bool reprobe = false;
char *stubDriverPath = NULL;
char *driverLink = NULL;
char *path = NULL; /* reused for different purposes */
- char *newDriverName = NULL;
+ char *stubDriverName = dev->stubDriver;
virErrorPtr err = NULL;
if (!(stubDriverPath = virPCIDriverDir(stubDriverName)) ||
- !(driverLink = virPCIFile(dev->name, "driver")) ||
- VIR_STRDUP(newDriverName, stubDriverName) < 0)
+ !(driverLink = virPCIFile(dev->name, "driver")))
goto cleanup;
if (virFileExists(driverLink)) {
VIR_FREE(driverLink);
VIR_FREE(path);
- if (result < 0) {
- VIR_FREE(newDriverName);
+ if (result < 0)
virPCIDeviceUnbindFromStub(dev);
- } else {
- VIR_FREE(dev->stubDriver);
- dev->stubDriver = newDriverName;
- }
if (err)
virSetError(err);
return -1;
}
- if (virPCIDeviceBindToStub(dev, dev->stubDriver) < 0)
+ if (virPCIDeviceBindToStub(dev) < 0)
return -1;
/* Add *a copy of* the dev into list inactiveDevs, if