linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: Hyunchul Lee <cheol.lee@lge.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>,
	adrian.hunter@intel.com, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-mtd@lists.infradead.org,
	kernel-team@lge.com
Subject: Re: [PATCH 2/2] ubifs: Fix memory leak in RENAME_WHITEOUT error path in do_rename
Date: Wed, 17 May 2017 09:01:17 +0200	[thread overview]
Message-ID: <a30a5f31-105e-823f-9336-80cf14cc8f9e@nod.at> (raw)
In-Reply-To: <1494979082-19414-1-git-send-email-cheol.lee@lge.com>

Hyunchul,

Am 17.05.2017 um 01:58 schrieb Hyunchul Lee:
> in RENAME_WHITEOUT error path, fscrypt_name should be freed.
> 
> Signed-off-by: Hyunchul Lee <cheol.lee@lge.com>
> ---
>  fs/ubifs/dir.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index df67236..0d5f8e7 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -1385,17 +1385,14 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>  
>  		dev = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS);
>  		if (!dev) {
> -			ubifs_release_budget(c, &req);
> -			ubifs_release_budget(c, &ino_req);
> -			return -ENOMEM;
> +			err = -ENOMEM;
> +			goto out_release;
>  		}
>  
>  		err = do_tmpfile(old_dir, old_dentry, S_IFCHR | WHITEOUT_MODE, &whiteout);
>  		if (err) {
> -			ubifs_release_budget(c, &req);
> -			ubifs_release_budget(c, &ino_req);
>  			kfree(dev);
> -			return err;
> +			goto out_release;
>  		}
>  
>  		whiteout->i_state |= I_LINKABLE;
> @@ -1483,12 +1480,10 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>  
>  		err = ubifs_budget_space(c, &wht_req);
>  		if (err) {
> -			ubifs_release_budget(c, &req);
> -			ubifs_release_budget(c, &ino_req);
>  			kfree(whiteout_ui->data);
>  			whiteout_ui->data_len = 0;
>  			iput(whiteout);
> -			return err;
> +			goto out_release;
>  		}
>  
>  		inc_nlink(whiteout);
> @@ -1543,6 +1538,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
>  		iput(whiteout);
>  	}
>  	unlock_4_inodes(old_dir, new_dir, new_inode, whiteout);
> +out_release:
>  	ubifs_release_budget(c, &ino_req);
>  	ubifs_release_budget(c, &req);
>  	fscrypt_free_filename(&old_nm);
> 

Good find too. :-)
This function needs a cleanup, it is much longer than it should be.

Thanks,
//richard

      reply	other threads:[~2017-05-17  7:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-16 23:58 [PATCH 2/2] ubifs: Fix memory leak in RENAME_WHITEOUT error path in do_rename Hyunchul Lee
2017-05-17  7:01 ` Richard Weinberger [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=a30a5f31-105e-823f-9336-80cf14cc8f9e@nod.at \
    --to=richard@nod.at \
    --cc=adrian.hunter@intel.com \
    --cc=cheol.lee@lge.com \
    --cc=dedekind1@gmail.com \
    --cc=kernel-team@lge.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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).