提交 8238fd66 编写于 作者: P Peter Krempa

node: Don't return invalid pointers

Commit 4337bc57 introduced code that would in certain error paths
unref the last reference of a pointer, but return it.

Clear the pointers before returning them.
上级 d1904241
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册