On Thu, 2020-07-23 at 09:29 +0800, Hao Wang wrote: > > From 3ad3fae4f2562a11bef8dcdd25b6a7e0b00d4e2c Mon Sep 17 00:00:00 > > 2001 > From: Hao Wang <wanghao232@xxxxxxxxxx> > Date: Sat, 18 Jul 2020 15:43:30 +0800 > Subject: [PATCH] client: fix memory leak in client msg > > When closing client->waitDispatch in virNetClientIOEventLoopRemoveAll > or virNetClientIOEventLoopRemoveDone, VIR_FREE() is called to free > call->msg directly, resulting in leak of the memory call->msg->buffer > points to. > Use virNetMessageFree(call->msg) instead of VIR_FREE(call->msg). > > Signed-off-by: Hao Wang <wanghao232@xxxxxxxxxx> > --- > src/rpc/virnetclient.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c > index 441f1502a6..f899493b64 100644 > --- a/src/rpc/virnetclient.c > +++ b/src/rpc/virnetclient.c > @@ -1519,7 +1519,7 @@ static bool > virNetClientIOEventLoopRemoveDone(virNetClientCallPtr call, > if (call->expectReply) > VIR_WARN("Got a call expecting a reply but without a > waiting thread"); > virCondDestroy(&call->cond); > - VIR_FREE(call->msg); > + virNetMessageFree(call->msg); > VIR_FREE(call); > } > > @@ -1546,7 +1546,7 @@ > virNetClientIOEventLoopRemoveAll(virNetClientCallPtr call, > > VIR_DEBUG("Removing call %p", call); > virCondDestroy(&call->cond); > - VIR_FREE(call->msg); > + virNetMessageFree(call->msg); > VIR_FREE(call); > return true; > } > -- > 2.23.0 > > Reviewed-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>