linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Pavel Reichl <preichl@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH] mkfs: Fix memory leak
Date: Tue, 24 May 2022 14:08:14 -0700	[thread overview]
Message-ID: <Yo1JPr6yvQGzUNBB@magnolia> (raw)
In-Reply-To: <Yo1I5N1IMXdHKUcw@magnolia>

On Tue, May 24, 2022 at 02:06:44PM -0700, Darrick J. Wong wrote:
> On Tue, May 24, 2022 at 10:40:40PM +0200, Pavel Reichl wrote:
> > 'value' is allocated by strup() in getstr(). It
> 
> Nit: strdup, not strup.
> 
> > needs to be freed as we do not keep any permanent
> > reference to it.
> > 
> > Signed-off-by: Pavel Reichl <preichl@redhat.com>
> 
> With that fixed,
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> 
> --D
> 
> > ---
> >  mkfs/xfs_mkfs.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> > index 01d2e8ca..a37d6848 100644
> > --- a/mkfs/xfs_mkfs.c
> > +++ b/mkfs/xfs_mkfs.c
> > @@ -1714,6 +1714,7 @@ naming_opts_parser(
> >  		} else {
> >  			cli->sb_feat.dir_version = getnum(value, opts, subopt);
> >  		}
> > +		free((char *)value);

...well, that, and the ^^^^ cast here isn't necessary.

--D

> >  		break;
> >  	case N_FTYPE:
> >  		cli->sb_feat.dirftype = getnum(value, opts, subopt);
> > -- 
> > 2.36.1
> > 

  reply	other threads:[~2022-05-24 21:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-24 20:40 [PATCH] mkfs: Fix memory leak Pavel Reichl
2022-05-24 21:06 ` Darrick J. Wong
2022-05-24 21:08   ` Darrick J. Wong [this message]
2022-05-24 21:13     ` Pavel Reichl
2022-05-24 21:27       ` Darrick J. Wong

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=Yo1JPr6yvQGzUNBB@magnolia \
    --to=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=preichl@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 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).