linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [nfs-utils PATCH] mountd: Fix memory leak in getexportent
@ 2015-02-20 18:49 Scott Mayhew
  2015-02-26 19:36 ` Steve Dickson
  0 siblings, 1 reply; 2+ messages in thread
From: Scott Mayhew @ 2015-02-20 18:49 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

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@redhat.com>
---
 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)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [nfs-utils PATCH] mountd: Fix memory leak in getexportent
  2015-02-20 18:49 [nfs-utils PATCH] mountd: Fix memory leak in getexportent Scott Mayhew
@ 2015-02-26 19:36 ` Steve Dickson
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2015-02-26 19:36 UTC (permalink / raw)
  To: Scott Mayhew; +Cc: linux-nfs



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@redhat.com>
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)
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-26 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-20 18:49 [nfs-utils PATCH] mountd: Fix memory leak in getexportent Scott Mayhew
2015-02-26 19:36 ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).