Skip to contentSkip to conversation

tomoyo: fix potential use after free

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

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

PATCH 1/1 tomoyo: fix potential use after free

The original code returns a freed pointer. This function is expected to return NULL on errors.

security/tomoyo/common.c +1 -0
index ff51f10..ef89947 100644
@@ -886,6 +886,7 @@ static struct tomoyo_profile *tomoyo_find_or_assign_new_profile(const unsigned
 	ptr = kmalloc(sizeof(*ptr), GFP_KERNEL);
 	if (!tomoyo_memory_ok(ptr)) {
 		kfree(ptr);
+		ptr = NULL;
 		goto ok;
 	}
 	for (i = 0; i < TOMOYO_MAX_CONTROL_INDEX; i++)
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Dan Carpenter

The original code returns a freed pointer. This function is expected to return NULL on errors.

Oh, thank you.
James, please send this patch to 2.6.34-rc1 .

Quoted 12 lines
security/tomoyo/common.c +1 -0
index ff51f10..ef89947 100644
@@ -886,6 +886,7 @@ static struct tomoyo_profile *tomoyo_find_or_assign_new_profile(const unsigned
 	ptr = kmalloc(sizeof(*ptr), GFP_KERNEL);
 	if (!tomoyo_memory_ok(ptr)) {
 		kfree(ptr);
+		ptr = NULL;
 		goto ok;
 	}
 	for (i = 0; i < TOMOYO_MAX_CONTROL_INDEX; i++)