summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorStefan Lengfeld <s.lengfeld@phytec.de>2016-11-07 16:10:56 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-11-08 08:55:48 +0100
commit7649dc9ec971d0988c9bf1e9d9c004fa284d81b5 (patch)
tree617b3a9c772ad04a3a8d0090a5c113a79eceb964 /commands
parente6876cde693ebffd87ae270197e7bf60a94edcaa (diff)
downloadbarebox-7649dc9ec971d0988c9bf1e9d9c004fa284d81b5.tar.gz
barebox-7649dc9ec971d0988c9bf1e9d9c004fa284d81b5.tar.xz
commands: spi: fix chip select validation
The chip selects are numbered 0..(max chip selects - 1). Chip select with number <max chip selects> is invalid. Fix the check for that. Using the out of bound chip select may hang your board. Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/spi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/commands/spi.c b/commands/spi.c
index 21db9ae237..6603b34b67 100644
--- a/commands/spi.c
+++ b/commands/spi.c
@@ -68,8 +68,8 @@ static int do_spi(int argc, char *argv[])
return -ENODEV;
}
- if (spi.chip_select > spi.master->num_chipselect) {
- printf("spi chip select (%d)> master num chipselect (%d)\n",
+ if (spi.chip_select >= spi.master->num_chipselect) {
+ printf("spi chip select (%d) >= master num chipselect (%d)\n",
spi.chip_select, spi.master->num_chipselect);
return -EINVAL;
}