* Re: [Cluster-devel] [PATCH] gfs2: Add check for mempool_alloc
@ 2022-04-01 3:37 Jiasheng Jiang
2022-04-01 4:46 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Jiasheng Jiang @ 2022-04-01 3:37 UTC (permalink / raw)
To: hch; +Cc: rpeterso, agruenba, cluster-devel, linux-kernel, Jiasheng Jiang
On Wed, 30 Mar 2022 11:56:41 +0800 Christoph Hellwig wrote:
>> As the potential failure of mempool_alloc(),
>> it could return NULL pointer.
>> Therefore, it should be better to check it
>> in order to avoid the dereference of the NULL
>> pointer.
>>
>> Fixes: e8c92ed76900 ("GFS2: Clean up log write code path")
>> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
>
> Please explain how it could fail to start with.
I think that for safety, the cost of redundant and harmless
check is acceptable.
Also, checking after allocation is a good program pattern.
Therefore, it should be better to check it although it is
hard to fail.
Thanks,
Jiang
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Cluster-devel] [PATCH] gfs2: Add check for mempool_alloc
2022-04-01 3:37 [Cluster-devel] [PATCH] gfs2: Add check for mempool_alloc Jiasheng Jiang
@ 2022-04-01 4:46 ` Christoph Hellwig
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2022-04-01 4:46 UTC (permalink / raw)
To: Jiasheng Jiang; +Cc: hch, rpeterso, agruenba, cluster-devel, linux-kernel
On Fri, Apr 01, 2022 at 11:37:55AM +0800, Jiasheng Jiang wrote:
> >> Fixes: e8c92ed76900 ("GFS2: Clean up log write code path")
> >> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> >
> > Please explain how it could fail to start with.
>
> I think that for safety, the cost of redundant and harmless
> check is acceptable.
> Also, checking after allocation is a good program pattern.
> Therefore, it should be better to check it although it is
> hard to fail.
Please take a look at the implemetation and documentation of
mempool_alloc again. Thewhole point of that function is that it will
not fail for allocations that can sleep.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Cluster-devel] [PATCH] gfs2: Add check for mempool_alloc
2022-03-11 8:36 Jiasheng Jiang
@ 2022-03-30 15:56 ` Christoph Hellwig
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2022-03-30 15:56 UTC (permalink / raw)
To: Jiasheng Jiang; +Cc: rpeterso, agruenba, cluster-devel, linux-kernel
On Fri, Mar 11, 2022 at 04:36:16PM +0800, Jiasheng Jiang wrote:
> As the potential failure of mempool_alloc(),
> it could return NULL pointer.
> Therefore, it should be better to check it
> in order to avoid the dereference of the NULL
> pointer.
>
> Fixes: e8c92ed76900 ("GFS2: Clean up log write code path")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Please explain how it could fail to start with.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-01 4:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 3:37 [Cluster-devel] [PATCH] gfs2: Add check for mempool_alloc Jiasheng Jiang
2022-04-01 4:46 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2022-03-11 8:36 Jiasheng Jiang
2022-03-30 15:56 ` [Cluster-devel] " Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome