[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] tools/libxl: close the logfile_w and null file descriptors in libxl__spawn_qdisk_backend() error path



On Mon, Mar 16, 2015 at 10:09:29AM +0000, Koushik Chakravarty wrote:
> Signed-off-by: Koushik Chakravarty <koushik.chakravarty@xxxxxxxxxx>
> CC: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
> CC: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> CC: Ian Campbell <ian.campbell@xxxxxxxxxx>
> CC: Wei Liu <wei.liu2@xxxxxxxxxx>
> ---
>  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

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.