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:
parent
e6876cde69
commit
7649dc9ec9
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue