linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: fangwei1@huawei.com, David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH] jffs2: fix a memleak in read_direntry()
Date: Sun, 4 Oct 2015 22:47:58 +0100	[thread overview]
Message-ID: <20151004214758.GA27301@localhost> (raw)
In-Reply-To: <1443497035-25220-1-git-send-email-fangwei1@huawei.com>

On Tue, Sep 29, 2015 at 11:23:55AM +0800, fangwei1@huawei.com wrote:
> From: Wei Fang <fangwei1@huawei.com>
> 
> Need to free the memory allocated for 'fd' if failed to read all
> of the remainder name.
> 
> Signed-off-by: Wei Fang <fangwei1@huawei.com>

Patch looks OK to me, and obvious. Applied, but I'm open to comments.

Brian

> ---
>  fs/jffs2/readinode.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
> index 28e0aab..bfebbf1 100644
> --- a/fs/jffs2/readinode.c
> +++ b/fs/jffs2/readinode.c
> @@ -660,8 +660,12 @@ static inline int read_direntry(struct jffs2_sb_info *c, struct jffs2_raw_node_r
>  
>  		err = jffs2_flash_read(c, (ref_offset(ref)) + read,
>  				rd->nsize - already, &read, &fd->name[already]);
> -		if (unlikely(read != rd->nsize - already) && likely(!err))
> +		if (unlikely(read != rd->nsize - already) && likely(!err)) {
> +			jffs2_free_full_dirent(fd);
> +			JFFS2_ERROR("short read: wanted %d bytes, got %zd\n",
> +				    rd->nsize - already, read);
>  			return -EIO;
> +		}
>  
>  		if (unlikely(err)) {
>  			JFFS2_ERROR("read remainder of name: error %d\n", err);
> -- 
> 1.7.1
> 

      reply	other threads:[~2015-10-04 21:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-29  3:23 [PATCH] jffs2: fix a memleak in read_direntry() fangwei1
2015-10-04 21:47 ` Brian Norris [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=20151004214758.GA27301@localhost \
    --to=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=fangwei1@huawei.com \
    --cc=linux-mtd@lists.infradead.org \
    /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).