iio: adc: qcom-spmi-adc5-gen3: Fix off by one in adc5_gen3_get_fw_channel_data()
Subsystems (3)
PATCH 1/1 iio: adc: qcom-spmi-adc5-gen3: Fix off by one in adc5_gen3_get_fw_channel_data()
The > in "if (chan > ADC5_MAX_CHANNEL)" should be >= to prevent an out of bound read of the adc->data->adc_chans[] array.
---
This email is a free service from the Smatch-CI project [smatch.sf.net].
drivers/iio/adc/qcom-spmi-adc5-gen3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/qcom-spmi-adc5-gen3.c +1 -1
@@ -482,7 +482,7 @@ static int adc5_gen3_get_fw_channel_data(struct adc5_chip *adc, sid =FIELD_GET (ADC5_GEN3_VIRTUAL_SID_MASK , chan); chan =FIELD_GET (ADC5_GEN3_CHANNEL_MASK , chan); -if (chan >ADC5_MAX_CHANNEL ) +if (chan >=ADC5_MAX_CHANNEL )return dev_err_probe (dev, -EINVAL ,"%s invalid channel number %d\n" , name, chan);
Signature · 1 line
2.53.0
Quoted 6 lines · Dan Carpenter
The > in "if (chan >
ADC5_MAX_CHANNEL)" should be >= to prevent an out of bound read of the adc->data->adc_chans[] array.Fixes baff45179e90 ("iio: adc: Add support for QCOM PMIC5 Gen3 ADC")Signed-off-by Dan Carpenter <[email protected]>---
Konrad
Jonathan Cameron
maintainerQuoted 10 lines · On Fri, 10 Apr 2026 12:15:41 +0200 Konrad Dybcio…
Quoted 6 lines · Dan Carpenter
The > in "if (chan >
ADC5_MAX_CHANNEL)" should be >= to prevent an out of bound read of the adc->data->adc_chans[] array.Fixes baff45179e90 ("iio: adc: Add support for QCOM PMIC5 Gen3 ADC")Signed-off-by Dan Carpenter <[email protected]>---
Reviewed-by Konrad Dybcio <[email protected]>
This was waiting on the char-misc pull requests going upstream so I could rebase my fixes branch. That's now happened, but I will rebase again on rc1 once available (as a pull request based mid merge window isn't the best plan!)
Anyhow applied to the fixes-togreg branch of iio.git.
Thanks,
Jonathan
Quoted 1 line
Konrad