diff mbox

qemu-ga: for w32, fix leaked handle ov.hEvent in ga_channel_write()

Message ID dc308d51a38be11f3de7dbc3f66e4716f8b559b3.1331835902.git.jcody@redhat.com
State New
Headers show

Commit Message

Jeff Cody March 15, 2012, 6:26 p.m. UTC
In the function ga_channel_write(), the handle ov.hEvent is created
by the call to CreateEvent(). However, the handle is not closed
prior to the function return.

This patch closes the handle before the return of the function.

Kudos to Paolo Bonzini for spotting this bug.

Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 qga/channel-win32.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Comments

Michael Roth March 15, 2012, 6:39 p.m. UTC | #1
On Thu, Mar 15, 2012 at 02:26:18PM -0400, Jeff Cody wrote:
> In the function ga_channel_write(), the handle ov.hEvent is created
> by the call to CreateEvent(). However, the handle is not closed
> prior to the function return.
> 
> This patch closes the handle before the return of the function.
> 
> Kudos to Paolo Bonzini for spotting this bug.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>

Acked-by: Michael Roth <mdroth@linux.vnet.ibm.com>

> ---
>  qga/channel-win32.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/qga/channel-win32.c b/qga/channel-win32.c
> index 190251b..16bf44a 100644
> --- a/qga/channel-win32.c
> +++ b/qga/channel-win32.c
> @@ -259,6 +259,10 @@ static GIOStatus ga_channel_write(GAChannel *c, const char *buf, size_t size,
>          *count = written;
>      }
> 
> +    if (ov.hEvent) {
> +        CloseHandle(ov.hEvent);
> +        ov.hEvent = NULL;
> +    }
>      return status;
>  }
> 
> -- 
> 1.7.9.rc2.1.g69204
>
Stefan Hajnoczi March 19, 2012, 11 a.m. UTC | #2
On Thu, Mar 15, 2012 at 02:26:18PM -0400, Jeff Cody wrote:
> In the function ga_channel_write(), the handle ov.hEvent is created
> by the call to CreateEvent(). However, the handle is not closed
> prior to the function return.
> 
> This patch closes the handle before the return of the function.
> 
> Kudos to Paolo Bonzini for spotting this bug.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  qga/channel-win32.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan
diff mbox

Patch

diff --git a/qga/channel-win32.c b/qga/channel-win32.c
index 190251b..16bf44a 100644
--- a/qga/channel-win32.c
+++ b/qga/channel-win32.c
@@ -259,6 +259,10 @@  static GIOStatus ga_channel_write(GAChannel *c, const char *buf, size_t size,
         *count = written;
     }
 
+    if (ov.hEvent) {
+        CloseHandle(ov.hEvent);
+        ov.hEvent = NULL;
+    }
     return status;
 }