linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH SLUB 1/2] duplicate the cache name in saved_alias list
@ 2012-06-25  9:53 Li Zhong
  2012-06-25  9:54 ` [PATCH powerpc 2/2] kfree the cache name of pgtable cache if SLUB is used Li Zhong
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Li Zhong @ 2012-06-25  9:53 UTC (permalink / raw)
  To: LKML
  Cc: Christoph Lameter, Pekka Enberg, linux-mm, Paul Mackerras,
	Matt Mackall, PowerPC email list

SLUB duplicates the cache name in kmem_cache_create(). However if the
cache could be merged to others during early booting, the name pointer
is saved in saved_alias list, and the string needs to be kept valid
before slab_sysfs_init() is called. 

This patch tries to duplicate the cache name in saved_alias list, so
that the cache name could be safely kfreed after calling
kmem_cache_create(), if that name is kmalloced. 

Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com>
---
 mm/slub.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index 8c691fa..3dc8ed5 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5373,6 +5373,11 @@ static int sysfs_slab_alias(struct kmem_cache *s,
const char *name)
 
 	al->s = s;
 	al->name = name;
+	al->name = kstrdup(name, GFP_KERNEL);
+	if (!al->name) {
+		kfree(al);
+		return -ENOMEM;
+	}
 	al->next = alias_list;
 	alias_list = al;
 	return 0;
@@ -5409,6 +5414,7 @@ static int __init slab_sysfs_init(void)
 		if (err)
 			printk(KERN_ERR "SLUB: Unable to add boot slab alias"
 					" %s to sysfs\n", s->name);
+		kfree(al->name);
 		kfree(al);
 	}
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2012-07-09  1:49 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-25  9:53 [PATCH SLUB 1/2] duplicate the cache name in saved_alias list Li Zhong
2012-06-25  9:54 ` [PATCH powerpc 2/2] kfree the cache name of pgtable cache if SLUB is used Li Zhong
2012-06-29  0:45   ` Benjamin Herrenschmidt
2012-06-29  1:41     ` Zhong Li
2012-07-03 18:48   ` Christoph Lameter
2012-07-03 20:36     ` Christoph Lameter
2012-07-04  9:00       ` Li Zhong
2012-07-04 12:40         ` Glauber Costa
2012-07-05  1:41           ` Li Zhong
2012-07-05  8:23             ` Glauber Costa
2012-07-05  9:29               ` Li Zhong
2012-07-06 10:13                 ` Glauber Costa
2012-07-09  1:48                   ` Li Zhong
2012-06-25 10:54 ` [PATCH SLUB 1/2] duplicate the cache name in saved_alias list Wanlong Gao
2012-06-26  2:49   ` Li Zhong
2012-06-25 11:10 ` Glauber Costa
2012-06-26  2:58   ` Li Zhong
2012-06-27  7:53 ` [PATCH SLUB 1/2 v2] " Li Zhong

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).