From: Linus Torvalds <torvalds@linux-foundation.org>
To: Roland Dreier <rdreier@cisco.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>, Andi Kleen <ak@suse.de>,
Christoph Lameter <clameter@sgi.com>,
linux-kernel@vger.kernel.org,
"Michael S. Tsirkin" <mst@dev.mellanox.co.il>
Subject: Re: kmalloc zero size changes break i386
Date: Thu, 19 Jul 2007 11:11:59 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.0.999.0707191107570.27353@woody.linux-foundation.org> (raw)
In-Reply-To: <adamyxsfmnc.fsf@cisco.com>
On Thu, 19 Jul 2007, Roland Dreier wrote:
>
> I think the oops below is related -- Michael reports that avoiding
> kmalloc(0) in the mlx4_ib driver makes it go away.
Ok, I think I see it: I think the mm/slab.c conversion of kmalloc(0) is
totally broken.
The problem? It returns ZERO_SIZE_PTR from __find_general_cachep(), not
from __kmalloc(). So anythign that uses __find_general_cachep() will get
an invalid cachep pointer, which was not the point.
We're deprecating SLAB, and a lot of people are already using SLUB,
which hid this.
Does something like this fix it?
Christoph, please go over this and see if there are other cases like that.
Linus
---
diff --git a/mm/slab.c b/mm/slab.c
index 88bc633..4bc4bc0 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -775,8 +775,6 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
*/
BUG_ON(malloc_sizes[INDEX_AC].cs_cachep == NULL);
#endif
- if (!size)
- return ZERO_SIZE_PTR;
while (size > csizep->cs_size)
csizep++;
@@ -3684,6 +3682,9 @@ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,
{
struct kmem_cache *cachep;
+ if (!size)
+ return ZERO_SIZE_PTR;
+
/* If you want to save a few bytes .text space: replace
* __ with kmem_.
* Then kmalloc uses the uninlined functions instead of the inline
next prev parent reply other threads:[~2007-07-19 18:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-19 10:01 Andi Kleen
2007-07-19 14:08 ` Pekka Enberg
2007-07-19 15:17 ` Roland Dreier
2007-07-19 18:11 ` Linus Torvalds [this message]
2007-07-19 19:03 ` Pekka Enberg
2007-07-19 19:19 ` Linus Torvalds
2007-07-19 21:03 ` Andi Kleen
2007-07-20 7:12 ` Pekka J Enberg
2007-07-20 7:18 ` Pekka J Enberg
2007-07-20 19:13 ` [PATCH] Fix ZERO_OR_NULL_PTR(ZERO_SIZE_PTR) Roland Dreier
2007-07-19 17:01 ` kmalloc zero size changes break i386 Andi Kleen
2007-07-19 15:57 ` Linus Torvalds
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=alpine.LFD.0.999.0707191107570.27353@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=ak@suse.de \
--cc=clameter@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@dev.mellanox.co.il \
--cc=penberg@cs.helsinki.fi \
--cc=rdreier@cisco.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
all inboxes | Powered by JetHome®