Re: [nfs-utils PATCH] mountd: Fix memory leak in getexportent

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

 




On 02/20/2015 01:49 PM, Scott Mayhew wrote:
> Valgrind shows that the memory allocated for ee.e_hostname in
> getexportent() is being leaked.  While there _is_ a call to xfree(), by
> the time it gets called the leak's already happened.  Moving the xfree()
> call so that it occurs before the assignment that overwrites ee fixes
> this.
> 
> Signed-off-by: Scott Mayhew <smayhew@xxxxxxxxxx>
Committed! 

steved.

> ---
>  support/nfs/exports.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/support/nfs/exports.c b/support/nfs/exports.c
> index eb782b9..4b17d3c 100644
> --- a/support/nfs/exports.c
> +++ b/support/nfs/exports.c
> @@ -154,6 +154,7 @@ getexportent(int fromkernel, int fromexports)
>  		}
>  	}
>  
> +	xfree(ee.e_hostname);
>  	ee = def_ee;
>  
>  	/* Check for default client */
> @@ -176,7 +177,6 @@ getexportent(int fromkernel, int fromexports)
>  		if (!has_default_opts)
>  			xlog(L_WARNING, "No options for %s %s: suggest %s(sync) to avoid warning", ee.e_path, exp, exp);
>  	}
> -	xfree(ee.e_hostname);
>  	ee.e_hostname = xstrdup(hostname);
>  
>  	if (parseopts(opt, &ee, fromexports && !has_default_subtree_opts, NULL) < 0)
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux