[PATCH 08/10] iio: adc: qcom-spmi-adc5-gen3: Reject empty reg property in probe

From: Lee Jones

Date: Thu Nov 19 2026 - 10:33:57 EST


If a firmware node supplies an empty reg property,
device_property_count_u32() returns 0, which passes the negative error
check in adc5_gen3_probe() and leaves num_sdams set to 0. Subsequent
zero-length allocations return ZERO_SIZE_PTR, which is then dereferenced
when requesting the VADC SDAM interrupt, and num_sdams * 8 - 1 wraps in
unsigned comparisons when counting TM channels.

Return -EINVAL when device_property_count_u32() reports zero elements.

Fixes: baff45179e90 ("iio: adc: Add support for QCOM PMIC5 Gen3 ADC")
Closes: https://sashiko.dev/#/bug/linux-d8ad5868-82f5-4c97-bc67-84ceebb10a1a
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/iio/adc/qcom-spmi-adc5-gen3.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/iio/adc/qcom-spmi-adc5-gen3.c b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
index 52f039795418..9102346feea9 100644
--- a/drivers/iio/adc/qcom-spmi-adc5-gen3.c
+++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
@@ -756,6 +756,8 @@ static int adc5_gen3_probe(struct platform_device *pdev)
ret = device_property_count_u32(dev, "reg");
if (ret < 0)
return ret;
+ if (!ret)
+ return -EINVAL;

adc->dev_data.num_sdams = ret;

--
2.56.1.708.g77570a6a1d-goog