public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gfs2: add error handling for kmem_cache_zalloc
@ 2018-06-12  3:38 Zhouyang Jia
  2018-06-12  7:24 ` cgxu519
  0 siblings, 1 reply; 4+ messages in thread
From: Zhouyang Jia @ 2018-06-12  3:38 UTC (permalink / raw)
  Cc: Zhouyang Jia, Bob Peterson, Andreas Gruenbacher, cluster-devel,
	linux-kernel

When kmem_cache_zalloc fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling kmem_cache_zalloc.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
 fs/gfs2/trans.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index 064c9a0..da81eb4 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -130,6 +130,9 @@ static struct gfs2_bufdata *gfs2_alloc_bufdata(struct gfs2_glock *gl,
 	struct gfs2_bufdata *bd;
 
 	bd = kmem_cache_zalloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL);
+	if (!bd)
+		return NULL;
+
 	bd->bd_bh = bh;
 	bd->bd_gl = gl;
 	bd->bd_ops = lops;
-- 
2.7.4


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

end of thread, other threads:[~2018-06-12 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-12  3:38 [PATCH] gfs2: add error handling for kmem_cache_zalloc Zhouyang Jia
2018-06-12  7:24 ` cgxu519
2018-06-12  8:23   ` Andreas Gruenbacher
2018-06-12 12:18   ` [Cluster-devel] " Steven Whitehouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox