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


On 06/11/2018 09:29 PM, Zhouyang Jia wrote:
> When kmem_cache_create fails, the lack of error-handling code may
> cause unexpected results.
>
> This patch adds error-handling code after calling kmem_cache_create.
>
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> ---
> net/decnet/dn_route.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
> index e747650..2b743c7 100644
> --- a/net/decnet/dn_route.c
> +++ b/net/decnet/dn_route.c
> @@ -1861,6 +1861,9 @@ void __init dn_route_init(void)
> dn_dst_ops.kmem_cachep =
> kmem_cache_create("dn_dst_cache", sizeof(struct dn_route), 0,
> SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
> + if (!dn_dst_ops.kmem_cachep)
> + panic("Failed to create dn_dst_cache cache\n");
> +

Not needed, since SLAB_PANIC would have paniced the box earlier.

> dst_entries_init(&dn_dst_ops);
> timer_setup(&dn_route_timer, dn_dst_check_expire, 0);
> dn_route_timer.expires = jiffies + decnet_dst_gc_interval * HZ;
>

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