mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
Fix a reference leak for node devices.
There were some major, and some minor bugs having to do with the reference counting of node devices in daemon/remote.c. Some functions were completely failing to unreference node devices; this would lead to many open file descriptors, which would eventually fail. The minor bugs were along the same lines, but were in rarely used error paths. Signed-off-by: Chris Lalancette <clalance@redhat.com> Signed-off-by: Matthias Bolte <matthias.bolte@googlemail.com>
This commit is contained in:
parent
6d9743158c
commit
3003c46d13
@ -5012,11 +5012,13 @@ remoteDispatchNodeDeviceGetParent (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
/* remoteDispatchClientRequest will free this. */
|
||||
char **parent_p;
|
||||
if (VIR_ALLOC(parent_p) < 0) {
|
||||
virNodeDeviceFree(dev);
|
||||
remoteDispatchOOMError(rerr);
|
||||
return -1;
|
||||
}
|
||||
*parent_p = strdup(parent);
|
||||
if (*parent_p == NULL) {
|
||||
virNodeDeviceFree(dev);
|
||||
remoteDispatchOOMError(rerr);
|
||||
return -1;
|
||||
}
|
||||
@ -5048,6 +5050,7 @@ remoteDispatchNodeDeviceNumOfCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
|
||||
ret->num = virNodeDeviceNumOfCaps(dev);
|
||||
if (ret->num < 0) {
|
||||
virNodeDeviceFree(dev);
|
||||
remoteDispatchConnError(rerr, conn);
|
||||
return -1;
|
||||
}
|
||||
@ -5076,6 +5079,7 @@ remoteDispatchNodeDeviceListCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
if (args->maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
|
||||
virNodeDeviceFree(dev);
|
||||
remoteDispatchFormatError(rerr,
|
||||
"%s", _("maxnames > REMOTE_NODE_DEVICE_NAME_LIST_MAX"));
|
||||
return -1;
|
||||
@ -5083,6 +5087,7 @@ remoteDispatchNodeDeviceListCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
|
||||
/* Allocate return buffer. */
|
||||
if (VIR_ALLOC_N(ret->names.names_val, args->maxnames) < 0) {
|
||||
virNodeDeviceFree(dev);
|
||||
remoteDispatchOOMError(rerr);
|
||||
return -1;
|
||||
}
|
||||
@ -5091,11 +5096,13 @@ remoteDispatchNodeDeviceListCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
virNodeDeviceListCaps (dev, ret->names.names_val,
|
||||
args->maxnames);
|
||||
if (ret->names.names_len == -1) {
|
||||
virNodeDeviceFree(dev);
|
||||
remoteDispatchConnError(rerr, conn);
|
||||
VIR_FREE(ret->names.names_val);
|
||||
return -1;
|
||||
}
|
||||
|
||||
virNodeDeviceFree(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -5119,10 +5126,12 @@ remoteDispatchNodeDeviceDettach (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
if (virNodeDeviceDettach(dev) == -1) {
|
||||
virNodeDeviceFree(dev);
|
||||
remoteDispatchConnError(rerr, conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
virNodeDeviceFree(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -5146,10 +5155,12 @@ remoteDispatchNodeDeviceReAttach (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
if (virNodeDeviceReAttach(dev) == -1) {
|
||||
virNodeDeviceFree(dev);
|
||||
remoteDispatchConnError(rerr, conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
virNodeDeviceFree(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -5173,10 +5184,12 @@ remoteDispatchNodeDeviceReset (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
if (virNodeDeviceReset(dev) == -1) {
|
||||
virNodeDeviceFree(dev);
|
||||
remoteDispatchConnError(rerr, conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
virNodeDeviceFree(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -5223,10 +5236,12 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
if (virNodeDeviceDestroy(dev) == -1) {
|
||||
virNodeDeviceFree(dev);
|
||||
remoteDispatchConnError(rerr, conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
virNodeDeviceFree(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user