All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gfs2: Add check for mempool_alloc
@ 2022-03-11  8:36 ` Jiasheng Jiang
  0 siblings, 0 replies; 4+ messages in thread
From: Jiasheng Jiang @ 2022-03-11  8:36 UTC (permalink / raw)
  To: rpeterso, agruenba; +Cc: cluster-devel, linux-kernel, Jiasheng Jiang

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>
---
 fs/gfs2/log.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index f0ee3ff6f9a8..10dd09e9b0e4 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -837,6 +837,9 @@ void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
 		return;
 
 	page = mempool_alloc(gfs2_page_pool, GFP_NOIO);
+	if (!page)
+		return;
+
 	lh = page_address(page);
 	clear_page(lh);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Cluster-devel] [PATCH] gfs2: Add check for mempool_alloc
@ 2022-03-11  8:36 ` Jiasheng Jiang
  0 siblings, 0 replies; 4+ messages in thread
From: Jiasheng Jiang @ 2022-03-11  8:36 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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>
---
 fs/gfs2/log.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index f0ee3ff6f9a8..10dd09e9b0e4 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -837,6 +837,9 @@ void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
 		return;
 
 	page = mempool_alloc(gfs2_page_pool, GFP_NOIO);
+	if (!page)
+		return;
+
 	lh = page_address(page);
 	clear_page(lh);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Cluster-devel] [PATCH] gfs2: Add check for mempool_alloc
  2022-03-11  8:36 ` [Cluster-devel] " Jiasheng Jiang
@ 2022-03-30 15:56   ` Christoph Hellwig
  -1 siblings, 0 replies; 4+ 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] 4+ messages in thread

* [Cluster-devel] [PATCH] gfs2: Add check for mempool_alloc
@ 2022-03-30 15:56   ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2022-03-30 15:56 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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] 4+ messages in thread

end of thread, other threads:[~2022-03-30 15:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11  8:36 [PATCH] gfs2: Add check for mempool_alloc Jiasheng Jiang
2022-03-11  8:36 ` [Cluster-devel] " Jiasheng Jiang
2022-03-30 15:56 ` Christoph Hellwig
2022-03-30 15:56   ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.