[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <BANLkTi=Jdxu7am8-jhJbT0t-uhNmW4zWhw@mail.gmail.com>
Date: Fri, 6 May 2011 21:28:04 +0300
From: Maxin John <maxin.john@...il.com>
To: Christoph Lameter <cl@...ux-foundation.org>
Cc: Pekka Enberg <penberg@...nel.org>, Matt Mackall <mpm@...enic.com>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: [PATCH] slub: slub_def.h: needs additional check for "index"
In slub_def.h file, the kmalloc_index() may return -1 for some special cases.
If that negative return value gets assigned to "index", it might lead to issues
later as the variable "index" is used as index to array "kmalloc_caches" in :
return kmalloc_caches[index];
Please let me know your comments.
Signed-off-by: Maxin B. John <maxin.john@...il.com>
---
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 45ca123..3db4b33 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -211,7 +211,7 @@ static __always_inline struct kmem_cache
*kmalloc_slab(size_t size)
{
int index = kmalloc_index(size);
- if (index == 0)
+ if (index <= 0)
return NULL;
return kmalloc_caches[index];
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists