From 38f898e0b54f5f1e7db92bec755fb55115d43de8 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Tue, 18 Feb 2025 17:17:46 -0600 Subject: [PATCH] iio: adc: ad4695: simplify getting oversampling_ratio MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We already have a local variable that holds a pointer to st->channels_cfg[chan->scan_index]. Use that to simplify the code. Signed-off-by: David Lechner Reviewed-by: Trevor Gamblin Reviewed-by: Nuno Sá Link: https://patch.msgid.link/20250218-iio-adc-ad4695-fix-out-of-bounds-array-access-v1-2-57fef8c7a3fd@baylibre.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad4695.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad4695.c b/drivers/iio/adc/ad4695.c index d42dea494302d..8222c8ab29402 100644 --- a/drivers/iio/adc/ad4695.c +++ b/drivers/iio/adc/ad4695.c @@ -1175,7 +1175,7 @@ static int ad4695_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_OVERSAMPLING_RATIO: switch (chan->type) { case IIO_VOLTAGE: - *val = st->channels_cfg[chan->scan_index].oversampling_ratio; + *val = cfg->oversampling_ratio; return IIO_VAL_INT; default: return -EINVAL; -- 2.47.3