mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
node: Don't return invalid pointers
Commit 4337bc57be introduced code that would in certain error paths
unref the last reference of a pointer, but return it.
Clear the pointers before returning them.
This commit is contained in:
@@ -241,8 +241,10 @@ nodeDeviceLookupByName(virConnectPtr conn, const char *name)
|
||||
goto cleanup;
|
||||
|
||||
if ((ret = virGetNodeDevice(conn, name))) {
|
||||
if (VIR_STRDUP(ret->parent, obj->def->parent) < 0)
|
||||
if (VIR_STRDUP(ret->parent, obj->def->parent) < 0) {
|
||||
virObjectUnref(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
@@ -285,8 +287,10 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
|
||||
goto out;
|
||||
|
||||
if ((dev = virGetNodeDevice(conn, obj->def->name))) {
|
||||
if (VIR_STRDUP(dev->parent, obj->def->parent) < 0)
|
||||
if (VIR_STRDUP(dev->parent, obj->def->parent) < 0) {
|
||||
virObjectUnref(dev);
|
||||
dev = NULL;
|
||||
}
|
||||
}
|
||||
virNodeDeviceObjUnlock(obj);
|
||||
goto out;
|
||||
|
||||
@@ -5331,8 +5331,10 @@ testNodeDeviceLookupByName(virConnectPtr conn, const char *name)
|
||||
goto cleanup;
|
||||
|
||||
if ((ret = virGetNodeDevice(conn, name))) {
|
||||
if (VIR_STRDUP(ret->parent, obj->def->parent) < 0)
|
||||
if (VIR_STRDUP(ret->parent, obj->def->parent) < 0) {
|
||||
virObjectUnref(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
||||
Reference in New Issue
Block a user