Skip to content

Commit

Permalink
Blackfin: add some bounds checking to peripheral_request
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Barry Song authored and Mike Frysinger committed Dec 15, 2009
1 parent 2985712 commit 89e84ee
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/blackfin/kernel/bfin_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 89e84ee

Please sign in to comment.