linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sh: intc_prio_data() test before subtraction on unsigned
@ 2008-09-09 21:02 roel kluin
  2008-09-10  3:03 ` Paul Mundt
  0 siblings, 1 reply; 2+ messages in thread
From: roel kluin @ 2008-09-09 21:02 UTC (permalink / raw)
  To: lethal, linux-kernel

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);

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

* Re: [PATCH] sh: intc_prio_data() test before subtraction on unsigned
  2008-09-09 21:02 [PATCH] sh: intc_prio_data() test before subtraction on unsigned roel kluin
@ 2008-09-10  3:03 ` Paul Mundt
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Mundt @ 2008-09-10  3:03 UTC (permalink / raw)
  To: roel kluin; +Cc: linux-kernel

On Tue, Sep 09, 2008 at 11:02:43PM +0200, roel kluin wrote:
> bit is unsigned, so test before subtraction
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>

Applied, thanks.

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

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

end of thread, other threads:[~2008-09-10  3:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-09 21:02 [PATCH] sh: intc_prio_data() test before subtraction on unsigned roel kluin
2008-09-10  3:03 ` Paul Mundt

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).