From: Steve Dickson <SteveD@redhat.com>
To: Scott Mayhew <smayhew@redhat.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [nfs-utils PATCH] mountd: Fix memory leak in getexportent
Date: Thu, 26 Feb 2015 14:36:21 -0500 [thread overview]
Message-ID: <54EF75B5.5090808@RedHat.com> (raw)
In-Reply-To: <1424458167-58324-1-git-send-email-smayhew@redhat.com>
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)
>
prev parent reply other threads:[~2015-02-26 19:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 18:49 [nfs-utils PATCH] mountd: Fix memory leak in getexportent Scott Mayhew
2015-02-26 19:36 ` Steve Dickson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54EF75B5.5090808@RedHat.com \
--to=steved@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=smayhew@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.