Blackfin: add some bounds checking to peripheral_request
authorBarry Song <barry.song@analog.com>
Wed, 16 Sep 2009 04:36:29 +0000 (04:36 +0000)
committerMike Frysinger <vapier@gentoo.org>
Tue, 15 Dec 2009 05:13:46 +0000 (00:13 -0500)
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 <barry.song@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
arch/blackfin/kernel/bfin_gpio.c

index 22705eeff34f5b64c4f510cc4a781a18d6afc0f8..c4161e03df78523e282cf9793fbaabc1679cffe9 100644 (file)
@@ -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