Skip to contentSkip to conversation

tomoyo: cleanup. don't store bogus pointer

PATCH In review Dan Carpenter 3 participants 3 messages Aug 7, 2010 – Aug 15, 2010

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

PATCH 1/1 tomoyo: cleanup. don't store bogus pointer

If domain is NULL then &domain->list is a bogus address. Let's leave head->r.domain NULL instead of saving an unusable pointer.

This is just a cleanup. The current code always checks head->r.eof before dereferencing head->r.domain.

security/tomoyo/common.c +4 -2
index ef43995..a4dc2d5 100644
@@ -768,8 +768,10 @@ static bool tomoyo_select_one(struct tomoyo_io_buffer *head, const char *data)
 		return true; /* Do nothing if open(O_WRONLY). */
 	memset(&head->r, 0, sizeof(head->r));
 	head->r.print_this_domain_only = true;
-	head->r.eof = !domain;
-	head->r.domain = &domain->list;
+	if (domain)
+		head->r.domain = &domain->list;
+	else
+		head->r.eof = 1;
 	tomoyo_io_printf(head, "# select %s\n", data);
 	if (domain && domain->is_deleted)
 		tomoyo_io_printf(head, "# This is a deleted domain.\n");
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Dan Carpenter

If domain is NULL then &domain->list is a bogus address. Let's leave head->r.domain NULL instead of saving an unusable pointer.

This is just a cleanup. The current code always checks head->r.eof before dereferencing head->r.domain.

I see. Thank you.

maintainer
#2 lore raw
In reply to Dan Carpenter
Quoted 5 lines · Tetsuo Handa
Quoted 3 lines · Dan Carpenter

If domain is NULL then &domain->list is a bogus address. Let's leave head->r.domain NULL instead of saving an unusable pointer.

Quoted 8 lines
Quoted 4 lines

This is just a cleanup. The current code always checks head->r.eof before dereferencing head->r.domain.

I see. Thank you.

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next

Signature · 2 lines
James Morris
<[email protected]>