mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00: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:
parent
d190424105
commit
8238fd6624
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user