All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools/libxl: close the logfile_w and null file descriptors in libxl__spawn_qdisk_backend() error path
@ 2015-03-18 12:39 Koushik Chakravarty
  2015-03-20 10:10 ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Koushik Chakravarty @ 2015-03-18 12:39 UTC (permalink / raw)
  To: xen-devel
  Cc: Wei Liu, Ian Jackson, Ian Campbell, Koushik Chakravarty,
	Stefano Stabellini

Signed-off-by: Koushik Chakravarty <koushik.chakravarty@citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl_dm.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index cb006df..2678be2 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1508,7 +1508,7 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss)
     flexarray_t *dm_args;
     char **args;
     const char *dm;
-    int logfile_w, null, rc;
+    int logfile_w, null = -1, rc;
     uint32_t domid = dmss->guest_domid;
 
     /* Always use qemu-xen as device model */
@@ -1534,6 +1534,10 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss)
         goto error;
     }
     null = open("/dev/null", O_RDONLY);
+    if (null < 0) {
+       rc = ERROR_FAIL;
+       goto error;
+    }
 
     dmss->guest_config = NULL;
     /*
@@ -1568,6 +1572,8 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss)
 
 error:
     assert(rc);
+    if (logfile_w >= 0) close(logfile_w);
+    if (null >= 0) close(null);
     dmss->callback(egc, dmss, rc);
     return;
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] tools/libxl: close the logfile_w and null file descriptors in libxl__spawn_qdisk_backend() error path
@ 2015-03-16 10:09 Koushik Chakravarty
  2015-03-17 15:53 ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Koushik Chakravarty @ 2015-03-16 10:09 UTC (permalink / raw)
  To: xen-devel
  Cc: Wei Liu, Ian Jackson, Ian Campbell, Koushik Chakravarty,
	Stefano Stabellini

Signed-off-by: Koushik Chakravarty <koushik.chakravarty@citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl_dm.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index cb006df..161401c 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1508,7 +1508,7 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss)
     flexarray_t *dm_args;
     char **args;
     const char *dm;
-    int logfile_w, null, rc;
+    int logfile_w, null = -1, rc;
     uint32_t domid = dmss->guest_domid;
 
     /* Always use qemu-xen as device model */
@@ -1534,6 +1534,10 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss)
         goto error;
     }
     null = open("/dev/null", O_RDONLY);
+    if (null < 0) {
+       rc = ERROR_FAIL;
+       goto error;
+    }
 
     dmss->guest_config = NULL;
     /*
@@ -1568,6 +1572,10 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss)
 
 error:
     assert(rc);
+    if(logfile_w >= 0)
+       close(logfile_w);
+    if(null >= 0)
+       close(null);
     dmss->callback(egc, dmss, rc);
     return;
 }
-- 
1.7.10.4

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

end of thread, other threads:[~2015-03-20 11:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-18 12:39 [PATCH] tools/libxl: close the logfile_w and null file descriptors in libxl__spawn_qdisk_backend() error path Koushik Chakravarty
2015-03-20 10:10 ` Wei Liu
2015-03-20 11:58   ` Ian Campbell
  -- strict thread matches above, loose matches on Subject: below --
2015-03-16 10:09 Koushik Chakravarty
2015-03-17 15:53 ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.