* [PATCH] net: add error handling for kmem_cache_create
@ 2018-06-12 4:29 Zhouyang Jia
2018-06-12 4:31 ` Eric Dumazet
0 siblings, 1 reply; 2+ messages in thread
From: Zhouyang Jia @ 2018-06-12 4:29 UTC (permalink / raw)
Cc: Zhouyang Jia, David S. Miller, Wei Wang, Martin KaFai Lau,
Kees Cook, Eric Dumazet, Florian Westphal, Joe Perches,
linux-decnet-user, netdev, linux-kernel
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");
+
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;
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: add error handling for kmem_cache_create
2018-06-12 4:29 [PATCH] net: add error handling for kmem_cache_create Zhouyang Jia
@ 2018-06-12 4:31 ` Eric Dumazet
0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2018-06-12 4:31 UTC (permalink / raw)
To: Zhouyang Jia
Cc: David S. Miller, Wei Wang, Martin KaFai Lau, Kees Cook,
Eric Dumazet, Florian Westphal, Joe Perches, linux-decnet-user,
netdev, linux-kernel
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;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-12 4:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-12 4:29 [PATCH] net: add error handling for kmem_cache_create Zhouyang Jia
2018-06-12 4:31 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).