Skip to contentSkip to conversation

powerpc: Prevent unsigned wrap in htab_dt_scan_page_sizes()

PATCH In review Roel Kluin 2 participants 2 messages Oct 14, 2009 PowerPC

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 powerpc: Prevent unsigned wrap in htab_dt_scan_page_sizes()

Check to prevent unsigned wrap of size before subtraction.

---
Is this maybe better or are we certain that size can't wrap?

arch/powerpc/mm/hash_utils_64.c +2 -2
index 1ade7eb..dd2d263 100644
@@ -287,7 +287,7 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
 		DBG("Page sizes from device-tree:\n");
 		size /= 4;
 		cur_cpu_spec->cpu_features &= ~(CPU_FTR_16M_PAGE);
-		while(size > 0) {
+		while(size >= 3) {
 			unsigned int shift = prop[0];
 			unsigned int slbenc = prop[1];
 			unsigned int lpnum = prop[2];
@@ -296,7 +296,7 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
 			int idx = -1;
 
 			size -= 3; prop += 3;
-			while(size > 0 && lpnum) {
+			while(size >= 2 && lpnum) {
 				if (prop[0] == shift)
 					lpenc = prop[1];
 				prop += 2; size -= 2;