linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Chen Wandun <chenwandun@huawei.com>
Cc: hughd@google.com, akpm@linux-foundation.org, linux-mm@kvack.org,
	 linux-kernel@vger.kernel.org, willy@infradead.org,
	david@redhat.com,  wangkefeng.wang@huawei.com
Subject: Re: [PATCH v3 1/3] mm/shmem: check return value of shmem_init_inodecache
Date: Sun, 5 Jun 2022 21:19:49 -0700 (PDT)	[thread overview]
Message-ID: <bc6accde-cd1f-8c44-2d94-9e6131b659b3@google.com> (raw)
In-Reply-To: <20220606034530.153505-2-chenwandun@huawei.com>

On Mon, 6 Jun 2022, Chen Wandun wrote:

> It will result in null pointer access if shmem_init_inodecache fail,
> so check return value of shmem_init_inodecache
> 
> Signed-off-by: Chen Wandun <chenwandun@huawei.com>

Thank you, but NAK.

It's a pity that you've been put to the trouble of sending a v3, sorry
about that: but if SLAB_PANIC no longer works, or panic() has taken to
returning, then that's what needs fixing, not shmem_init_inodecache().

Was this one supposed to be the bugfix?  And I'm afraid I don't care
for your "cleanups" in 2/3 and 3/3 either: a matter of taste, and our
tastes differ.

I'd rather not spend the time on these: maybe look for somewhere else
to change around than mm/shmem.c?  Or better, please help us all by
using your time to review the functional patches being posted.

Thanks,
Hugh

> ---
>  mm/shmem.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 12d45a03f7fc..7419ab219b97 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -3775,11 +3775,16 @@ static void shmem_init_inode(void *foo)
>  	inode_init_once(&info->vfs_inode);
>  }
>  
> -static void shmem_init_inodecache(void)
> +static int shmem_init_inodecache(void)
>  {
>  	shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
>  				sizeof(struct shmem_inode_info),
>  				0, SLAB_PANIC|SLAB_ACCOUNT, shmem_init_inode);
> +
> +	if (!shmem_inode_cachep)
> +		return -ENOMEM;
> +
> +	return 0;
>  }
>  
>  static void shmem_destroy_inodecache(void)
> @@ -3923,7 +3928,9 @@ void __init shmem_init(void)
>  {
>  	int error;
>  
> -	shmem_init_inodecache();
> +	error = shmem_init_inodecache();
> +	if (error)
> +		goto out2;
>  
>  	error = register_filesystem(&shmem_fs_type);
>  	if (error) {
> -- 
> 2.25.1


  reply	other threads:[~2022-06-06  4:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06  3:45 [PATCH v3 0/3] a few cleanup and bugfixes about shmem Chen Wandun
2022-06-06  3:45 ` [PATCH v3 1/3] mm/shmem: check return value of shmem_init_inodecache Chen Wandun
2022-06-06  4:19   ` Hugh Dickins [this message]
2022-06-06  9:39   ` Muchun Song
2022-06-06  3:45 ` [PATCH v3 2/3] mm/shmem: return error code directly for invalid addr Chen Wandun
2022-06-06  3:45 ` [PATCH v3 3/3] mm/shmem: rework calculation of inflated_addr in shmem_get_unmapped_area Chen Wandun

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=bc6accde-cd1f-8c44-2d94-9e6131b659b3@google.com \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=chenwandun@huawei.com \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@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