9
0
Fork 0

i2c: Fix barebox crash when 'count' is not set for i2c_read command

Running i2c_read without the 'count' setting causes an error and reboots.

barebox@Phytec phyCORE-i.MX27:/ i2c_read -b 1 -a 0x4a -r 0x00
ERROR: out of memory
no stack data available

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Alexander Shiyan 2012-05-11 19:42:18 +04:00 committed by Sascha Hauer
parent 3d0eeb7ef2
commit c7c32736bc
1 changed files with 1 additions and 1 deletions

View File

@ -170,7 +170,7 @@ static int do_i2c_read(int argc, char *argv[])
}
}
if ((addr < 0) || (reg < 0) || (count == 0) || (addr > 0x7F))
if ((addr < 0) || (reg < 0) || (count < 1) || (addr > 0x7F))
return COMMAND_ERROR_USAGE;
adapter = i2c_get_adapter(bus);