From: cgxu519@gmx.com Date: Tue, 12 Jun 2018 15:24:41 +0800 Subject: [Cluster-devel] [PATCH] gfs2: add error handling for kmem_cache_zalloc In-Reply-To: <1528774692-38990-1-git-send-email-jiazhouyang09@gmail.com> References: <1528774692-38990-1-git-send-email-jiazhouyang09@gmail.com> Message-ID: List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit > ? 2018?6?12????11:38?Zhouyang Jia ??? > > 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. Should not fail on this case. Thanks, Chengguang. > > Signed-off-by: Zhouyang Jia > --- > 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 >