[PATCH] sh: intc_prio_data() test before subtraction on unsigned

Previous thread: [PATCH 16/24] i386: convert hardware exception 17 to an interrupt gate by heukelum on Tuesday, September 9, 2008 - 12:56 pm. (35 messages)

Next thread: [2.6.27-rc5] inotify_read's ev_mutex vs do_page_fault's mmap_sem... by Daniel J Blueman on Tuesday, September 9, 2008 - 2:03 pm. (10 messages)
From: roel kluin
Date: Tuesday, September 9, 2008 - 2:02 pm

bit is unsigned, so test before subtraction

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/arch/sh/kernel/cpu/irq/intc.c b/arch/sh/kernel/cpu/irq/intc.c
index 8c70e20..94536d3 100644
--- a/arch/sh/kernel/cpu/irq/intc.c
+++ b/arch/sh/kernel/cpu/irq/intc.c
@@ -464,9 +464,10 @@ static unsigned int __init intc_prio_data(struct intc_desc *desc,
 			}
 
 			fn += (pr->reg_width >> 3) - 1;
-			bit = pr->reg_width - ((j + 1) * pr->field_width);
 
-			BUG_ON(bit < 0);
+			BUG_ON((j + 1) * pr->field_width > pr->reg_width);
+
+			bit = pr->reg_width - ((j + 1) * pr->field_width);
 
 			return _INTC_MK(fn, mode,
 					intc_get_reg(d, reg_e),
@@ -531,9 +532,10 @@ static unsigned int __init intc_sense_data(struct intc_desc *desc,
 
 			fn = REG_FN_MODIFY_BASE;
 			fn += (sr->reg_width >> 3) - 1;
-			bit = sr->reg_width - ((j + 1) * sr->field_width);
 
-			BUG_ON(bit < 0);
+			BUG_ON((j + 1) * sr->field_width > sr->reg_width);
+
+			bit = sr->reg_width - ((j + 1) * sr->field_width);
 
 			return _INTC_MK(fn, 0, intc_get_reg(d, sr->reg),
 					0, sr->field_width, bit);
--

From: Paul Mundt
Date: Tuesday, September 9, 2008 - 8:03 pm

Applied, thanks.

In the future, please make sure to CC linux-sh@vger.kernel.org on any SH
related patches.
--

Previous thread: [PATCH 16/24] i386: convert hardware exception 17 to an interrupt gate by heukelum on Tuesday, September 9, 2008 - 12:56 pm. (35 messages)

Next thread: [2.6.27-rc5] inotify_read's ev_mutex vs do_page_fault's mmap_sem... by Daniel J Blueman on Tuesday, September 9, 2008 - 2:03 pm. (10 messages)