Skip to contentSkip to conversation

tools/libxl: close the logfile_w and null file descriptors in libxl__spawn_qdisk_backend() error path

PATCH Superseded Koushik Chakravarty 3 participants 3 messages Mar 18, 2015 – Mar 20, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/libxl: close the logfile_w and null file descriptors in libxl__spawn_qdisk_backend() error path

CC Ian Jackson <[email protected]>
CC Stefano Stabellini <[email protected]>
CC Ian Campbell <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxl/libxl_dm.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/libxl/libxl_dm.c +7 -1
index cb006df..2678be2 100644
@@ -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;
 }
Signature · 1 line
1.7.10.4
#1 lore raw

I think this patch is identical to the one I just acked.

FWIW in the future there is no need to submit the same patch multiple times. We will ask you to resend if it is necessary.

Wei.

#2 lore raw
Quoted 1 line · Wei Liu

I think this patch is identical to the one I just acked.

Houshik, Having just applied this patch I now have no further patches from you in my queue, if there were others then please resend.

Ian.