linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: Prevent unsigned wrap in htab_dt_scan_page_sizes()
@ 2009-10-14 12:12 Roel Kluin
  2009-10-14 21:29 ` Paul Mackerras
  0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-10-14 12:12 UTC (permalink / raw)
  To: paulus, benh, linuxppc-dev; +Cc: Andrew Morton

Check to prevent unsigned wrap of size before subtraction.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Is this maybe better or are we certain that size can't wrap?

diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 1ade7eb..dd2d263 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -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;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] powerpc: Prevent unsigned wrap in htab_dt_scan_page_sizes()
  2009-10-14 12:12 [PATCH] powerpc: Prevent unsigned wrap in htab_dt_scan_page_sizes() Roel Kluin
@ 2009-10-14 21:29 ` Paul Mackerras
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Mackerras @ 2009-10-14 21:29 UTC (permalink / raw)
  To: Roel Kluin; +Cc: Andrew Morton, linuxppc-dev

Roel Kluin writes:

> Check to prevent unsigned wrap of size before subtraction.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> Is this maybe better or are we certain that size can't wrap?

Patch looks good, though while you're at it, you could add a space
after the "while".

Acked-by: Paul Mackerras <paulus@samba.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-14 21:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-14 12:12 [PATCH] powerpc: Prevent unsigned wrap in htab_dt_scan_page_sizes() Roel Kluin
2009-10-14 21:29 ` Paul Mackerras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).