From: Christoph Lameter <cl@linux-foundation.org>
To: Pekka J Enberg <penberg@cs.helsinki.fi>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] SLUB: Use WARN_ON instead of BUG_ON where appropriate
Date: Wed, 14 Jan 2009 11:45:37 -0600 (CST) [thread overview]
Message-ID: <Pine.LNX.4.64.0901141117070.26507@quilx.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0901141719560.12990@melkki.cs.Helsinki.FI>
On Wed, 14 Jan 2009, Pekka J Enberg wrote:
> From: Pekka Enberg <penberg@cs.helsinki.fi>
>
> It's better to WARN_ON and let the kernel limp along to increase the likelihood
> of an user detecting the error and reporting it to us.
That only works if a error condition can be signaled and be handled
appropriately.
> diff --git a/mm/slub.c b/mm/slub.c
> index 6392ae5..e4404a1 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1119,7 +1119,8 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
> void *last;
> void *p;
>
> - BUG_ON(flags & GFP_SLAB_BUG_MASK);
> + if (WARN_ON(flags & GFP_SLAB_BUG_MASK))
> + return NULL;
>
> page = allocate_slab(s,
> flags & (GFP_RECLAIM_MASK | GFP_CONSTRAINT_MASK), node);
Ok. this relies on kmalloc returning NULL to the app.
> @@ -4285,7 +4287,8 @@ static char *create_unique_id(struct kmem_cache *s)
> char *name = kmalloc(ID_STR_LENGTH, GFP_KERNEL);
> char *p = name;
>
> - BUG_ON(!name);
> + if (WARN_ON(!name))
> + return NULL;
>
> *p++ = ':';
> /*
> @@ -4304,7 +4307,8 @@ static char *create_unique_id(struct kmem_cache *s)
> if (p != name + 1)
> *p++ = '-';
> p += sprintf(p, "%07d", s->size);
> - BUG_ON(p > name + ID_STR_LENGTH - 1);
> + if (WARN_ON(p > name + ID_STR_LENGTH - 1))
> + return NULL;
> return name;
> }
>
NULL name? Guess the kfree will just be a nop but what does
kobject_init_and_add do with a NULL name?
> @@ -4333,6 +4337,8 @@ static int sysfs_slab_add(struct kmem_cache *s)
> * for the symlinks.
> */
> name = create_unique_id(s);
> + if (!name)
> + return -EINVAL;
> }
>
> s->kobj.kset = slab_kset;
>
-EINVAL may cause a panic anyways if called from create_kmalloc_cache.
next prev parent reply other threads:[~2009-01-14 17:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-14 15:20 Pekka J Enberg
2009-01-14 17:45 ` Christoph Lameter [this message]
2009-01-19 9:54 ` Pekka Enberg
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=Pine.LNX.4.64.0901141117070.26507@quilx.com \
--to=cl@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
/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
all inboxes | Powered by JetHome®