9
0
Fork 0

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>
This commit is contained in:
Stefan Lengfeld 2016-11-07 16:10:56 +01:00 committed by Sascha Hauer
parent e6876cde69
commit 7649dc9ec9
1 changed files with 2 additions and 2 deletions

View File

@ -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;
}