[PATCH v2 6/7] iio: adc: qcom-spmi-adc5-gen3: Reject empty reg property in probe
From: Lee Jones
Date: Mon Nov 23 2026 - 02:52:43 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 -ENOENT 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>
---
v1 => v2:
- Return -ENOENT instead of -EINVAL when reg is empty (Andy)
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 85450aa37e65..8e316aa88f48 100644
--- a/drivers/iio/adc/qcom-spmi-adc5-gen3.c
+++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
@@ -736,6 +736,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 -ENOENT;
adc->dev_data.num_sdams = ret;
--
2.56.1.750.gf70dc682cf-goog