Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Cc: Hugh Dickins <hughd@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	 Al Viro <viro@zeniv.linux.org.uk>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/shmem.c: Fix the missing unaccount on the failed path
Date: Sun, 20 Sep 2020 11:49:20 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LSU.2.11.2009201141510.4318@eggly.anvils> (raw)
In-Reply-To: <20200920163005.97079-1-tianjia.zhang@linux.alibaba.com>

On Mon, 21 Sep 2020, Tianjia Zhang wrote:

> In function __shmem_file_setup(), shmem_unacct_size() is forgotten
> on the failed path, so add it.
> 
> Fixes: 93dec2da7b234 ("... and switch shmem_file_setup() to alloc_file_pseudo()")
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> ---
>  mm/shmem.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 8e2b35ba93ad..591410dc3541 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -4200,8 +4200,10 @@ static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name, l
>  	if (!IS_ERR(res))
>  		res = alloc_file_pseudo(inode, mnt, name, O_RDWR,
>  				&shmem_file_operations);
> -	if (IS_ERR(res))
> +	if (IS_ERR(res)) {
>  		iput(inode);
> +		shmem_unacct_size(flags, size);
> +	}
>  	return res;
>  }
>  
> -- 
> 2.19.1.3.ge56e4f7

Looks mistaken to me.

Is this something you noticed by source inspection,
or something you have observed in practice?

I haven't tried exercising this path while injecting errors into
alloc_file_pseudo(); but what I'd expect to happen is that the
iput(inode), which you see already on that error path, will get
to evict the inode, which will entail calling shmem_evict_inode(),
which does that shmem_unacct_size() itself.

Hugh


  reply	other threads:[~2020-09-20 18:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-20 16:30 [PATCH] mm/shmem.c: Fix the missing unaccount on the failed path Tianjia Zhang
2020-09-20 18:49 ` Hugh Dickins [this message]
2020-09-22  5:27   ` Tianjia Zhang

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=alpine.LSU.2.11.2009201141510.4318@eggly.anvils \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tianjia.zhang@linux.alibaba.com \
    --cc=viro@zeniv.linux.org.uk \
    /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