From 89e84eeace5924f29a4f8f25cce9fcb083969974 Mon Sep 17 00:00:00 2001 From: Barry Song Date: Wed, 16 Sep 2009 04:36:29 +0000 Subject: Blackfin: add some bounds checking to peripheral_request The requested peripheral is turned into an index into some state arrays, so make sure the calculated index doesn't exceed the index. This occurs when using bogus pin values or the define headers are screwed up. Now we'll notice right away that something needs fixing instead of trying to track down random memory corruption. Signed-off-by: Barry Song Signed-off-by: Mike Frysinger --- arch/blackfin/kernel/bfin_gpio.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/blackfin') diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c index 22705eeff34f..c4161e03df78 100644 --- a/arch/blackfin/kernel/bfin_gpio.c +++ b/arch/blackfin/kernel/bfin_gpio.c @@ -762,6 +762,8 @@ int peripheral_request(unsigned short per, const char *label) if (!(per & P_DEFINED)) return -ENODEV; + BUG_ON(ident >= MAX_RESOURCES); + local_irq_save_hw(flags); /* If a pin can be muxed as either GPIO or peripheral, make -- cgit v1.2.1