xfs
[Top] [All Lists]

Re: [PATCH 4/6] libhandle: Fix handle leak in path_to_fshandle error pat

To: Eric Sandeen <sandeen@xxxxxxxxxx>
Subject: Re: [PATCH 4/6] libhandle: Fix handle leak in path_to_fshandle error paths
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Tue, 5 Aug 2014 09:31:40 -0400
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1406905159-12415-5-git-send-email-sandeen@xxxxxxxxxx>
References: <1406905159-12415-1-git-send-email-sandeen@xxxxxxxxxx> <1406905159-12415-5-git-send-email-sandeen@xxxxxxxxxx>
User-agent: Mutt/1.5.23 (2014-03-12)
On Fri, Aug 01, 2014 at 09:59:17AM -0500, Eric Sandeen wrote:
> path_to_fshandle calls obj_to_handle, which potentially
> allocates a handle, but the handle isn't freed on
> a subsequent error path.
> 
> Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
> ---
>  libhandle/handle.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/libhandle/handle.c b/libhandle/handle.c
> index 9f81483..3c1395a 100644
> --- a/libhandle/handle.c
> +++ b/libhandle/handle.c
> @@ -97,6 +97,7 @@ path_to_fshandle(
>               /* new filesystem. add it to the cache */
>               fdhp = malloc(sizeof(struct fdhash));
>               if (fdhp == NULL) {
> +                     free(*fshanp);

Might be a good idea to set *fshanp back to NULL here. It doesn't appear
to be an issue with current callers, however:

Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx>

>                       close(fd);
>                       errno = ENOMEM;
>                       return -1;
> -- 
> 1.7.1
> 
> _______________________________________________
> xfs mailing list
> xfs@xxxxxxxxxxx
> http://oss.sgi.com/mailman/listinfo/xfs

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