* [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
* Re: [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, 0 replies; 5+ messages in thread
From: Wei Liu @ 2015-03-17 15:53 UTC (permalink / raw)
To: Koushik Chakravarty
Cc: xen-devel, Wei Liu, Ian Jackson, Ian Campbell, Stefano Stabellini
On Mon, Mar 16, 2015 at 10:09:29AM +0000, Koushik Chakravarty wrote:
> 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);
Please add space between `if' and `('.
Also you can just write
if (logfile_w >= 0) close (logfile_w);
if (null >= 0) close (null);
Wei.
> dmss->callback(egc, dmss, rc);
> return;
> }
> --
> 1.7.10.4
^ permalink raw reply [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-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
* Re: [PATCH] tools/libxl: close the logfile_w and null file descriptors in libxl__spawn_qdisk_backend() error path
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
0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2015-03-20 10:10 UTC (permalink / raw)
To: Koushik Chakravarty
Cc: xen-devel, Wei Liu, Ian Jackson, Ian Campbell, Stefano Stabellini
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tools/libxl: close the logfile_w and null file descriptors in libxl__spawn_qdisk_backend() error path
2015-03-20 10:10 ` Wei Liu
@ 2015-03-20 11:58 ` Ian Campbell
0 siblings, 0 replies; 5+ messages in thread
From: Ian Campbell @ 2015-03-20 11:58 UTC (permalink / raw)
To: Wei Liu; +Cc: xen-devel, Ian Jackson, Koushik Chakravarty, Stefano Stabellini
On Fri, 2015-03-20 at 10:10 +0000, Wei Liu wrote:
> 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.
^ permalink raw reply [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.