xfs
[Top] [All Lists]

Re: [PATCH 5/6] xfs_io: fix leaks in parent_list()

To: Eric Sandeen <sandeen@xxxxxxxxxx>
Subject: Re: [PATCH 5/6] xfs_io: fix leaks in parent_list()
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Tue, 5 Aug 2014 09:31:47 -0400
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1406905159-12415-6-git-send-email-sandeen@xxxxxxxxxx>
References: <1406905159-12415-1-git-send-email-sandeen@xxxxxxxxxx> <1406905159-12415-6-git-send-email-sandeen@xxxxxxxxxx>
User-agent: Mutt/1.5.23 (2014-03-12)
On Fri, Aug 01, 2014 at 09:59:18AM -0500, Eric Sandeen wrote:
> parent_list() has instances where a handle is leaked,
> both by going out of scope, and on error paths.
> 
> Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
> ---

Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx>

>  io/parent.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/io/parent.c b/io/parent.c
> index 56e126d..0313119 100644
> --- a/io/parent.c
> +++ b/io/parent.c
> @@ -293,7 +293,7 @@ print_parent_entry(parent_t *parent, int fullpath)
>  static int
>  parent_list(int fullpath)
>  {
> -     void *handlep;
> +     void *handlep = NULL;
>       size_t handlen;
>       int error, i;
>       int retval = 1;
> @@ -313,6 +313,7 @@ parent_list(int fullpath)
>                               progname, path, strerror(errno));
>                       goto error;
>               }
> +             free_handle(fshandle, fshlen);
>       }
>  
>       if (path_to_handle(path, &handlep, &handlen) != 0) {
> @@ -325,7 +326,7 @@ parent_list(int fullpath)
>               if (!parentbuf) {
>                       fprintf(stderr, _("%s: unable to allocate parent 
> buffer: %s\n"),
>                               progname, strerror(errno));
> -                     return 1;
> +                     goto error;
>               }
>  
>               if (fullpath) {
> @@ -365,6 +366,7 @@ parent_list(int fullpath)
>  
>       retval = 0;
>  error:
> +     free(handlep);
>       free(parentbuf);
>       return retval;
>  }
> -- 
> 1.7.1
> 
> _______________________________________________
> xfs mailing list
> xfs@xxxxxxxxxxx
> http://oss.sgi.com/mailman/listinfo/xfs

<Prev in Thread] Current Thread [Next in Thread>