linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memcg: fix mutex not unlocked on memcg_create_kmem_cache fail path
@ 2014-01-30 16:01 Vladimir Davydov
  2014-01-30 21:01 ` Andrew Morton
  2014-01-30 21:09 ` David Rientjes
  0 siblings, 2 replies; 17+ messages in thread
From: Vladimir Davydov @ 2014-01-30 16:01 UTC (permalink / raw)
  To: akpm; +Cc: mhocko, linux-mm, linux-kernel

Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
---
 mm/memcontrol.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 19d5d4274e22..53385cd4e6f0 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3400,7 +3400,7 @@ void mem_cgroup_destroy_cache(struct kmem_cache *cachep)
 static struct kmem_cache *memcg_create_kmem_cache(struct mem_cgroup *memcg,
 						  struct kmem_cache *s)
 {
-	struct kmem_cache *new;
+	struct kmem_cache *new = NULL;
 	static char *tmp_name = NULL;
 	static DEFINE_MUTEX(mutex);	/* protects tmp_name */
 
@@ -3416,7 +3416,7 @@ static struct kmem_cache *memcg_create_kmem_cache(struct mem_cgroup *memcg,
 	if (!tmp_name) {
 		tmp_name = kmalloc(PATH_MAX, GFP_KERNEL);
 		if (!tmp_name)
-			return NULL;
+			goto out;
 	}
 
 	rcu_read_lock();
@@ -3426,12 +3426,11 @@ static struct kmem_cache *memcg_create_kmem_cache(struct mem_cgroup *memcg,
 
 	new = kmem_cache_create_memcg(memcg, tmp_name, s->object_size, s->align,
 				      (s->flags & ~SLAB_PANIC), s->ctor, s);
-
 	if (new)
 		new->allocflags |= __GFP_KMEMCG;
 	else
 		new = s;
-
+out:
 	mutex_unlock(&mutex);
 	return new;
 }
-- 
1.7.10.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 17+ messages in thread
* Re: [PATCH] memcg: fix mutex not unlocked on memcg_create_kmem_cache fail path
@ 2014-01-31 15:39 boxerapp
  0 siblings, 0 replies; 17+ messages in thread
From: boxerapp @ 2014-01-31 15:39 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Rientjes, Vladimir Davydov, mhocko, linux-kernel, linux-mm

[-- Attachment #1: Type: text/plain, Size: 1050 bytes --]

I've added this to my to-do list. On January 30, 2014 at 4:09:02 PM CST, Andrew Morton  wrote:On Thu, 30 Jan 2014 14:04:12 -0800 (PST) David Rientjes  wrote:> On Thu, 30 Jan 2014, Andrew Morton wrote:> > > > Yeah, it shouldn't be temporary it should be the one and only allocation. > > > We should construct the name in memcg_create_kmem_cache() and be done with > > > it.> > > > Could. That would require converting memcg_create_kmem_cache() to take > > a va_list and call kasprintf() on it.> > > > Why? We already construct the name in memcg_create_kmem_cache() > appropriately, we just want to avoid the kstrdup() in > kmem_cache_create_memcg() since it's pointless like my patch does.oh, OK, missed that.The problem now is that the string at kmem_cache.name is PATH_MAXbytes, and PATH_MAX is huuuuuuuge.--To unsubscribe from this list: send the line "unsubscribe linux-kernel" inthe body of a message to majordomo@vger.kernel.orgMore majordomo info at http://vger.kernel.org/majordomo-info.htmlPlease read the FAQ at http://www.tux.org/lkml/     

[-- Attachment #2: Type: text/html, Size: 1462 bytes --]

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

end of thread, other threads:[~2014-01-31 15:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-30 16:01 [PATCH] memcg: fix mutex not unlocked on memcg_create_kmem_cache fail path Vladimir Davydov
2014-01-30 21:01 ` Andrew Morton
2014-01-30 21:14   ` David Rientjes
2014-01-30 21:29     ` Andrew Morton
2014-01-30 21:38       ` David Rientjes
2014-01-30 21:50         ` Andrew Morton
2014-01-30 22:04           ` David Rientjes
2014-01-30 22:09             ` Andrew Morton
2014-01-30 22:13               ` David Rientjes
2014-01-30 22:15                 ` Andrew Morton
2014-01-30 22:39                   ` David Rientjes
2014-01-31  6:53                     ` Vladimir Davydov
2014-01-31 10:42                       ` David Rientjes
2014-01-31 11:29                         ` Vladimir Davydov
2014-01-30 21:36     ` David Rientjes
2014-01-30 21:09 ` David Rientjes
  -- strict thread matches above, loose matches on Subject: below --
2014-01-31 15:39 boxerapp

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