linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Eric Sandeen <sandeen@redhat.com>, linux-xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH] xfs_io: fix memory leak in add_enckey
Date: Mon, 11 Nov 2019 09:27:38 -0800	[thread overview]
Message-ID: <20191111172737.GB56300@gmail.com> (raw)
In-Reply-To: <a142f525-c45f-c245-58ad-879f94a636cb@sandeen.net>

On Mon, Nov 11, 2019 at 09:13:45AM -0600, Eric Sandeen wrote:
> On 11/7/19 3:58 PM, Eric Sandeen wrote:
> > On 11/7/19 3:46 PM, Eric Biggers wrote:
> >> On Thu, Nov 07, 2019 at 10:50:59AM -0600, Eric Sandeen wrote:
> >>> Invalid arguments to add_enckey will leak the "arg" allocation,
> >>> so fix that.
> >>>
> >>> Fixes: ba71de04 ("xfs_io/encrypt: add 'add_enckey' command")
> >>> Fixes-coverity-id: 1454644
> >>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> >>> ---
> >>>
> >>> diff --git a/io/encrypt.c b/io/encrypt.c
> >>> index 17d61cfb..c6a4e190 100644
> >>> --- a/io/encrypt.c
> >>> +++ b/io/encrypt.c
> >>> @@ -696,6 +696,7 @@ add_enckey_f(int argc, char **argv)
> >>>  				goto out;
> >>>  			break;
> >>>  		default:
> >>> +			free(arg);
> >>>  			return command_usage(&add_enckey_cmd);
> >>>  		}
> >>>  	}
> >>>
> >>
> >> The same leak happens later in the function too.  How about this instead:
> > 
> > whoops yes it does.  I kind of hate "retval = command_usage" but seeing the
> > memset of the key on the way out it's probably prudent to have one common
> > exit point after the function gets started.
> > 
> > Care to send this as a formal patch?
> 
> <interprets silence as a "no"> ;)
> 
> I'll just incorporate your fixes as an addendum to my patch, then.
> 
> -Eric

Sorry, I didn't receive this because I was dropped from Cc, and I'm not
currently subscribed to linux-xfs.  The patch you committed looks fine, thanks.

- Eric

  reply	other threads:[~2019-11-11 17:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-07 16:50 [PATCH] xfs_io: fix memory leak in add_enckey Eric Sandeen
2019-11-07 20:29 ` Bill O'Donnell
2019-11-07 21:46 ` Eric Biggers
2019-11-07 21:58   ` Eric Sandeen
2019-11-11 15:13     ` Eric Sandeen
2019-11-11 17:27       ` Eric Biggers [this message]
2019-11-11 18:07         ` Eric Sandeen
2019-11-14 21:09           ` Eric Biggers

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=20191111172737.GB56300@gmail.com \
    --to=ebiggers@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=sandeen@sandeen.net \
    /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).