Skip to content

Commit 0a5f45e

Browse files
cjd8jic23
authored andcommitted
iio: light: si1133: reset counter to prevent race condition
Sashiko reported a potential race condition happening when the driver returns an errno after a timeout in the si1133_command() function. The premature exit causes the hardware and software counters to become out of sync by not updating data->rsp_seq, therefore the internal hardware counter keeps incrementing. Fix this by adding a call to si1133_cmd_reset_counter() before returning from timeout. Fixes: e01e7ea ("iio: light: introduce si1133") Reported-by: sashiko-bot <sashiko-bot@kernel.org> Closes: https://sashiko.dev/#/message/20260428-si1133-checkup-v2-5-70ad14bfefe2%40gmail.com Assisted-by: gemini:gemini-3.1-pro-preview Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent ccf300c commit 0a5f45e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/iio/light/si1133.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ static int si1133_command(struct si1133_data *data, u8 cmd)
427427
dev_warn(dev,
428428
"Failed to read command 0x%02x, ret=%d\n",
429429
cmd, err);
430+
/*
431+
* Reset counter on err to prevent software and hardware
432+
* counters being out of sync.
433+
*/
434+
si1133_cmd_reset_counter(data);
430435
goto out;
431436
}
432437
}

0 commit comments

Comments
 (0)