lkml.org 
[lkml]   [2018]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] gfs2: add error handling for kmem_cache_zalloc
From
Date

> 在 2018年6月12日,上午11:38,Zhouyang Jia <jiazhouyang09@gmail.com> 写道:
>
> 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 <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
>

\
 
 \ /
  Last update: 2018-06-12 09:25    [W:0.061 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site