mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
rpc: Plug memory leak on virNetClientSendInternal() error path
Detected by Coverity. Leak introduced in commit 673adba
.
Two separate bugs here:
1. call was not freed on all error paths
2. virCondDestroy was called even if virCondInit failed
Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
ad8fa356a6
commit
773a4ea5e1
@ -1708,7 +1708,7 @@ static int virNetClientSendInternal(virNetClientPtr client,
|
|||||||
if (!client->sock || client->wantClose) {
|
if (!client->sock || client->wantClose) {
|
||||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("client socket is closed"));
|
_("client socket is closed"));
|
||||||
goto unlock;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virCondInit(&call->cond) < 0) {
|
if (virCondInit(&call->cond) < 0) {
|
||||||
@ -1729,16 +1729,16 @@ static int virNetClientSendInternal(virNetClientPtr client,
|
|||||||
|
|
||||||
ret = virNetClientIO(client, call);
|
ret = virNetClientIO(client, call);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
/* If partially sent, then the call is still on the dispatch queue */
|
/* If partially sent, then the call is still on the dispatch queue */
|
||||||
if (ret == 1) {
|
if (ret == 1) {
|
||||||
call->haveThread = false;
|
call->haveThread = false;
|
||||||
} else {
|
} else {
|
||||||
ignore_value(virCondDestroy(&call->cond));
|
ignore_value(virCondDestroy(&call->cond));
|
||||||
VIR_FREE(call);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock:
|
cleanup:
|
||||||
|
if (ret != 1)
|
||||||
|
VIR_FREE(call);
|
||||||
virNetClientUnlock(client);
|
virNetClientUnlock(client);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user