[PATCH] commands: spi: fix chip select validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 commands/spi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/commands/spi.c b/commands/spi.c
index 21db9ae..6603b34 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;
 	}
-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux