Skip to content

Commit

Permalink
drivers: ov2640: fix integer underflow in retry logic
Browse files Browse the repository at this point in the history
Properly stop retrying instead of underflowing uint8_t
fixes CID-487667 and CID-487767

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
  • Loading branch information
kartben committed Jan 28, 2025
1 parent 3f81c69 commit a253fe2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/video/ov2640.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ static int ov2640_write_reg(const struct i2c_dt_spec *spec, uint8_t reg_addr,
* just to be sure that the connection error is not caused by driver
* itself.
*/
while (tries--) {
while (tries-- > 0) {
if (!i2c_reg_write_byte_dt(spec, reg_addr, value)) {
return 0;
}
Expand All @@ -513,7 +513,7 @@ static int ov2640_read_reg(const struct i2c_dt_spec *spec, uint8_t reg_addr)
* just to be sure that the connection error is not caused by driver
* itself.
*/
while (tries--) {
while (tries-- > 0) {
if (!i2c_reg_read_byte_dt(spec, reg_addr, &value)) {
return value;
}
Expand Down

0 comments on commit a253fe2

Please sign in to comment.