[libvirt] [PATCH 0/2] Fix a couple of resource leaks

Resource a couple Coverity found resource leaks John Ferlan (2): daemon: Don't conditionally free @origErr in daemonStreamEvent tests: Free @fakerootdir in error path daemon/stream.c | 2 +- tests/qemumemlocktest.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) -- 2.9.4

Commit id '0fe4aa149' added @origErr, but since it's assigned outside the if condition, the free should be outside as well. Found by Coverity Signed-off-by: John Ferlan <jferlan@redhat.com> --- daemon/stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/stream.c b/daemon/stream.c index 5077ac8..49682f1 100644 --- a/daemon/stream.c +++ b/daemon/stream.c @@ -239,7 +239,6 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque) virStreamAbort(stream->st); if (origErr && origErr->code != VIR_ERR_OK) { virSetError(origErr); - virFreeError(origErr); } else { if (events & VIR_STREAM_EVENT_HANGUP) virReportError(VIR_ERR_RPC, @@ -248,6 +247,7 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque) virReportError(VIR_ERR_RPC, "%s", _("stream had I/O failure")); } + virFreeError(origErr); msg = virNetMessageNew(false); if (!msg) { -- 2.9.4

Commit id 'dd9b29dad' added this new variable, but didn't free it in one instance where status was returned to the caller. Found by Coverity Signed-off-by: John Ferlan <jferlan@redhat.com> --- tests/qemumemlocktest.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c index 268563d..66ebabb 100644 --- a/tests/qemumemlocktest.c +++ b/tests/qemumemlocktest.c @@ -80,8 +80,10 @@ mymain(void) if (!abs_top_srcdir) abs_top_srcdir = abs_srcdir "/.."; - if (qemuTestDriverInit(&driver) < 0) + if (qemuTestDriverInit(&driver) < 0) { + VIR_FREE(fakerootdir); return EXIT_FAILURE; + } driver.privileged = true; -- 2.9.4

On Thu, Jul 20, 2017 at 07:00:38AM -0400, John Ferlan wrote:
Resource a couple Coverity found resource leaks
John Ferlan (2): daemon: Don't conditionally free @origErr in daemonStreamEvent tests: Free @fakerootdir in error path
daemon/stream.c | 2 +- tests/qemumemlocktest.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)
ACK series. Erik
participants (2)
-
Erik Skultety
-
John Ferlan