From: Eric Dumazet <eric.dumazet@gmail.com>
To: Zhouyang Jia <jiazhouyang09@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Wei Wang <weiwan@google.com>, Martin KaFai Lau <kafai@fb.com>,
Kees Cook <keescook@chromium.org>,
Eric Dumazet <edumazet@google.com>,
Florian Westphal <fw@strlen.de>, Joe Perches <joe@perches.com>,
linux-decnet-user@lists.sourceforge.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: add error handling for kmem_cache_create
Date: Mon, 11 Jun 2018 21:31:47 -0700 [thread overview]
Message-ID: <17050ede-26b7-dfa5-91c5-e94da3e336e6@gmail.com> (raw)
In-Reply-To: <1528777798-40722-1-git-send-email-jiazhouyang09@gmail.com>
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;
>
prev parent reply other threads:[~2018-06-12 4:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 4:29 [PATCH] net: add error handling for kmem_cache_create Zhouyang Jia
2018-06-12 4:31 ` Eric Dumazet [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=17050ede-26b7-dfa5-91c5-e94da3e336e6@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=jiazhouyang09@gmail.com \
--cc=joe@perches.com \
--cc=kafai@fb.com \
--cc=keescook@chromium.org \
--cc=linux-decnet-user@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=weiwan@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).