[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8ad1aa0b-ff8d-6a9a-d516-16425b45a55a@huawei.com>
Date: Wed, 1 Jun 2022 21:34:40 +0800
From: Kefeng Wang <wangkefeng.wang@...wei.com>
To: Matthew Wilcox <willy@...radead.org>,
Chen Wandun <chenwandun@...wei.com>
CC: <hughd@...gle.com>, <akpm@...ux-foundation.org>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/4] mm/shmem: check return value of shmem_init_inodecache
On 2022/6/1 20:54, Matthew Wilcox wrote:
> On Wed, Jun 01, 2022 at 08:44:14PM +0800, Chen Wandun wrote:
>> -static void shmem_init_inodecache(void)
>> +static struct kmem_cache *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);
>> +
>> + return shmem_inode_cachep;
>> }
>>
>> static void shmem_destroy_inodecache(void)
>> @@ -3924,7 +3926,10 @@ void __init shmem_init(void)
>> {
>> int error;
>>
>> - shmem_init_inodecache();
>> + if (!shmem_init_inodecache()) {
>> + error = -ENOMEM;
>> + goto out2;
>> + }
> better to return the errno from shmem_init_inodecache():
>
> error = shmem_init_inodecache();
kmem_cache_create return a pointer to the cache on success, NULL on failureļ¼
so error = -ENOMEM; is right :)
> if (error)
> goto out2;
>
> .
Powered by blists - more mailing lists