Skip to contentSkip to conversation

x86, pat: Proper init of memtype subtree_max_end

tip:x86/urgent tip-bot for Venkatesh Pallipadi 1 participant 1 message Jun 11, 2010 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Commit-ID:  6a4f3b523779b67e7d560ed42652f8a59f2f9782
Gitweb:     http://git.kernel.org/tip/6a4f3b523779b67e7d560ed42652f8a59f2f9782
Author:     Venkatesh Pallipadi <[email protected]>
AuthorDate: Thu, 10 Jun 2010 17:45:01 -0700
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Fri, 11 Jun 2010 14:12:22 -0700

x86, pat: Proper init of memtype subtree_max_end

subtree_max_end that was recently added to struct memtype was not getting properly initialized resulting in

WARNING: kmemcheck: Caught 64-bit read from uninitialized memory in memtype_rb_augment_cb()
reported here
https://bugzilla.kernel.org/show_bug.cgi?id=16092

This change fixes the problem.

LKML-Reference: <[email protected]>

---
 arch/x86/mm/pat.c        |    2 +-
 arch/x86/mm/pat_rbtree.c |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
arch/x86/mm/pat.c +1 -1
index acc15b2..64121a1 100644
@@ -302,7 +302,7 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
 		return -EINVAL;
 	}
 
-	new  = kmalloc(sizeof(struct memtype), GFP_KERNEL);
+	new  = kzalloc(sizeof(struct memtype), GFP_KERNEL);
 	if (!new)
 		return -ENOMEM;
 
arch/x86/mm/pat_rbtree.c +1 -0
index f537087..f20eeec 100644
@@ -226,6 +226,7 @@ int rbt_memtype_check_insert(struct memtype *new, unsigned long *ret_type)
 		if (ret_type)
 			new->type = *ret_type;
 
+		new->subtree_max_end = new->end;
 		memtype_rb_insert(&memtype_rbroot, new);
 	}
 	return err;