Skip to contentSkip to conversation

memcontrol: fix potential null deref

PATCH In review Dan Carpenter 2 participants 2 messages Mar 13, 2010 – Mar 15, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memcontrol: fix potential null deref

There was a potential null deref introduced in:
c62b1a3b31b5 memcg: use generic percpu instead of private implementation

mm/memcontrol.c +4 -2
index 7973b52..e1e0996 100644
@@ -3691,8 +3691,10 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
 	else
 		mem = vmalloc(size);
 
-	if (mem)
-		memset(mem, 0, size);
+	if (!mem)
+		return NULL;
+
+	memset(mem, 0, size);
 	mem->stat = alloc_percpu(struct mem_cgroup_stat_cpu);
 	if (!mem->stat) {
 		if (size < PAGE_SIZE)
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · On Sat, 13 Mar 2010 17:56:21 +0300 Dan Carpenter <[email protected]> wrote:

There was a potential null deref introduced in:
c62b1a3b31b5 memcg: use generic percpu instead of private implementation

Thanks.

Quoted 24 lines
mm/memcontrol.c +4 -3
index 7973b52..e1e0996 100644
@@ -3691,8 +3691,10 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
 	else
 		mem = vmalloc(size);
 
-	if (mem)
-		memset(mem, 0, size);
+	if (!mem)
+		return NULL;
+
+	memset(mem, 0, size);
 	mem->stat = alloc_percpu(struct mem_cgroup_stat_cpu);
 	if (!mem->stat) {
 		if (size < PAGE_SIZE)
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/