qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qga: Fix handle fd leak in acquire_privilege()
@ 2014-05-19  7:26 arei.gonglei
  2014-05-19 15:04 ` Eric Blake
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: arei.gonglei @ 2014-05-19  7:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, mdroth, lcapitulino, Gonglei, Wang Rui

From: Gonglei <arei.gonglei@huawei.com>

token should be closed in all conditions.
So move CloseHandle(token) to "out" branch.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 qga/commands-win32.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index d793dd0..e769396 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -31,7 +31,7 @@
 
 static void acquire_privilege(const char *name, Error **errp)
 {
-    HANDLE token;
+    HANDLE token = NULL;
     TOKEN_PRIVILEGES priv;
     Error *local_err = NULL;
 
@@ -53,13 +53,15 @@ static void acquire_privilege(const char *name, Error **errp)
             goto out;
         }
 
-        CloseHandle(token);
     } else {
         error_set(&local_err, QERR_QGA_COMMAND_FAILED,
                   "failed to open privilege token");
     }
 
 out:
+    if (token) {
+        CloseHandle(token);
+    }
     if (local_err) {
         error_propagate(errp, local_err);
     }
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [Qemu-devel] [PULL 0/1] qemu-ga fixes for win32
@ 2014-06-05 19:41 Michael Roth
  2014-06-05 19:41 ` [Qemu-devel] [PATCH] qga: Fix handle fd leak in acquire_privilege() Michael Roth
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Roth @ 2014-06-05 19:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, arei.gonglei, qemu-stable

The following changes since commit e00fcfeab3d452cba3d0a08991a39ab15df66424:

  Merge remote-tracking branch 'remotes/awilliam/tags/vfio-pci-for-qemu-20140602.0' into staging (2014-06-03 14:37:43 +0100)

are available in the git repository at:


  git://github.com/mdroth/qemu.git qga-pull-2014-06-05

for you to fetch changes up to 374044f08fe18a18469b981812cd8695f5b3569c:

  qga: Fix handle fd leak in acquire_privilege() (2014-06-03 15:07:59 -0500)

----------------------------------------------------------------
Gonglei (1):
      qga: Fix handle fd leak in acquire_privilege()

 qga/commands-win32.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-06-05 19:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-19  7:26 [Qemu-devel] [PATCH] qga: Fix handle fd leak in acquire_privilege() arei.gonglei
2014-05-19 15:04 ` Eric Blake
2014-05-20 12:24 ` Yan Vugenfirer
2014-05-20 19:17 ` Luiz Capitulino
2014-05-20 19:46   ` Michael Roth
2014-05-21  9:00     ` Yan Vugenfirer
2014-05-21 10:11       ` Wangrui (K)
  -- strict thread matches above, loose matches on Subject: below --
2014-06-05 19:41 [Qemu-devel] [PULL 0/1] qemu-ga fixes for win32 Michael Roth
2014-06-05 19:41 ` [Qemu-devel] [PATCH] qga: Fix handle fd leak in acquire_privilege() Michael Roth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).