Skip to content
Snippets Groups Projects
Commit edd18cc7 authored by Zicheng Qu's avatar Zicheng Qu Committed by Greg Kroah-Hartman
Browse files

iio: gts: fix infinite loop for gain_to_scaletables()


commit 7452f8a0814bb73f739ee0dab60f099f3361b151 upstream.

In iio_gts_build_avail_time_table(), it is checked that gts->num_itime is
non-zero, but gts->num_itime is not checked in gain_to_scaletables(). The
variable time_idx is initialized as gts->num_itime - 1. This implies that
time_idx might initially be set to -1 (0 - 1 = -1). Consequently, using
while (time_idx--) could lead to an infinite loop.

Cc: stable@vger.kernel.org # v6.6+
Fixes: 38416c28 ("iio: light: Add gain-time-scale helpers")
Signed-off-by: default avatarZicheng Qu <quzicheng@huawei.com>
Reviewed-by: default avatarMatti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/20241031014626.2313077-1-quzicheng@huawei.com


Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 218ecc35
No related branches found
No related tags found
1 merge request!176🤖 Sync Bot: Update v6.12-ktn to Latest Stable Kernel (v6.12.4)
......@@ -205,7 +205,7 @@ static int gain_to_scaletables(struct iio_gts *gts, int **gains, int **scales)
memcpy(all_gains, gains[time_idx], gain_bytes);
new_idx = gts->num_hwgain;
while (time_idx--) {
while (time_idx-- > 0) {
for (j = 0; j < gts->num_hwgain; j++) {
int candidate = gains[time_idx][j];
int chk;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment