projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
53604db
)
spi_mpc83xx: reject invalid transfer sizes
author
Peter Korsgaard
<
[email protected]
>
Sat, 13 Sep 2008 09:33:15 +0000
(
02:33
-0700)
committer
Linus Torvalds
<
[email protected]
>
Sat, 13 Sep 2008 21:41:51 +0000
(14:41 -0700)
Error out on transfer length != multiple of bytes per word with -EINVAL.
Fixes a buffer overrun crash if length < bytes per word.
Signed-off-by: Peter Korsgaard <
[email protected]
>
Acked-by: Joakim Tjernlund <
[email protected]
>
Signed-off-by: David Brownell <
[email protected]
>
Signed-off-by: Andrew Morton <
[email protected]
>
Signed-off-by: Linus Torvalds <
[email protected]
>
drivers/spi/spi_mpc83xx.c
patch
|
blob
|
history
diff --git
a/drivers/spi/spi_mpc83xx.c
b/drivers/spi/spi_mpc83xx.c
index ab7ee445d8b29bdd8f1a1fd3db4ab955d2a3cf72..ac0e3e4b3c543e480028d90829c7f5606b7fde71 100644
(file)
--- a/
drivers/spi/spi_mpc83xx.c
+++ b/
drivers/spi/spi_mpc83xx.c
@@
-312,11
+312,20
@@
static int mpc83xx_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
if (t->bits_per_word)
bits_per_word = t->bits_per_word;
len = t->len;
- if (bits_per_word > 8)
+ if (bits_per_word > 8) {
+ /* invalid length? */
+ if (len & 1)
+ return -EINVAL;
len /= 2;
- if (bits_per_word > 16)
+ }
+ if (bits_per_word > 16) {
+ /* invalid length? */
+ if (len & 1)
+ return -EINVAL;
len /= 2;
+ }
mpc83xx_spi->count = len;
+
INIT_COMPLETION(mpc83xx_spi->done);
/* enable rx ints */