* [PATCH v3 0/3] iio: Fix Critical and High issues reported by Sashiko
@ 2026-12-02 20:21 Lee Jones
2026-12-02 20:21 ` [PATCH v3 1/3] iio: adc: qcom-spmi-adc5-gen3: Free TM auxiliary device wrapper in release callback Lee Jones
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Lee Jones @ 2026-12-02 20:21 UTC (permalink / raw)
To: lee
Cc: linux-kernel, Nuno Sá, Andy Shevchenko, David Lechner,
Jishnu Prakash, Jonathan Cameron, linux-arm-msm, linux-iio,
Mathieu Othacehe
This v3 series carries the remaining 3 IIO fixes from the original
Sashiko batch after the first 4 patches (adis, adxl313, pac1934) were
applied, rebased onto fixes-togreg with review feedback folded in.
These issues were reported by Sashiko.
v2 => v3:
- Drop the 4 patches already applied to fixes-togreg and testing
- Rebase onto fixes-togreg (resolving devm_kzalloc_obj() conversion in
qcom-spmi-adc5-gen3)
- isl29501: Fold frequency range validation into a single upfront guard
and switch to MICROHZ_PER_HZ (Andy)
v1 => v2:
- Drop patches already addressed or rejected in v1 review
- qcom-spmi-adc5-gen3: Move auxiliary_device_init() earlier, free
tm_props and OF node reference in release callback, and use
auxiliary_device_destroy() devm action (Jonathan, Andy)
- qcom-spmi-adc5-gen3: Return -ENOENT for empty reg property (Andy)
- isl29501: Use reverse Christmas tree ordering, grouped checks, and
units.h macros (Andy)
Cc: "Nuno Sá" <nuno.sa@analog.com>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: David Lechner <dlechner@baylibre.com>
Cc: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-iio@vger.kernel.org
Cc: Mathieu Othacehe <othacehe@gnu.org>
Lee Jones (3):
iio: adc: qcom-spmi-adc5-gen3: Free TM auxiliary device wrapper in
release callback
iio: adc: qcom-spmi-adc5-gen3: Reject empty reg property in probe
iio: proximity: isl29501: Fix division by zero and overflow in
isl29501_set_freq()
drivers/iio/adc/qcom-spmi-adc5-gen3.c | 59 +++++++++++++--------------
drivers/iio/proximity/isl29501.c | 11 +++--
2 files changed, 37 insertions(+), 33 deletions(-)
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 1/3] iio: adc: qcom-spmi-adc5-gen3: Free TM auxiliary device wrapper in release callback
2026-12-02 20:21 [PATCH v3 0/3] iio: Fix Critical and High issues reported by Sashiko Lee Jones
@ 2026-12-02 20:21 ` Lee Jones
2026-12-02 20:21 ` [PATCH v3 2/3] iio: adc: qcom-spmi-adc5-gen3: Reject empty reg property in probe Lee Jones
2026-12-02 20:21 ` [PATCH v3 3/3] iio: proximity: isl29501: Fix division by zero and overflow in isl29501_set_freq() Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-12-02 20:21 UTC (permalink / raw)
To: lee
Cc: linux-kernel, stable, Nuno Sá, Andy Shevchenko,
David Lechner, Jishnu Prakash, Jonathan Cameron, linux-arm-msm,
linux-iio
struct tm5_aux_dev_wrapper embeds a reference-counted struct
auxiliary_device, whose memory must be released from its dev.release
callback once the final device reference is dropped.
Allocating the wrapper and its tm_props array with parent-managed
devm_*() helpers and providing an empty adc5_gen3_aux_device_release()
causes parent devres teardown to free both allocations immediately when
the parent unbinds, even if external references to the embedded struct
device are still held. It also leaks the OF node reference taken by
device_set_of_node_from_dev().
Allocate the wrapper and tm_props array without devm, release them
together with the OF node reference in adc5_gen3_aux_device_release(),
and register auxiliary_device_destroy() via devm_add_action_or_reset()
once the auxiliary device has been added.
Fixes: baff45179e90 ("iio: adc: Add support for QCOM PMIC5 Gen3 ADC")
Closes: https://sashiko.dev/#/bug/linux-b738d116-f32b-4edf-aa73-77827b79a407
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
v2 => v3:
- Rebase onto fixes-togreg (resolving devm_kzalloc_obj() conversion)
v1 => v2:
- Include linux/container_of.h (Andy)
- Move auxiliary_device_init() earlier and drop devm_release_action()
unwinding in favour of a single auxiliary_device_destroy() devm
action (Jonathan, Andy)
- Move tm_props allocation out of devm and free it alongside the
wrapper and OF node reference in adc5_gen3_aux_device_release()
(Jonathan)
Cc: "Nuno Sá" <nuno.sa@analog.com>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: David Lechner <dlechner@baylibre.com>
Cc: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-iio@vger.kernel.org
drivers/iio/adc/qcom-spmi-adc5-gen3.c | 57 +++++++++++++--------------
1 file changed, 27 insertions(+), 30 deletions(-)
diff --git a/drivers/iio/adc/qcom-spmi-adc5-gen3.c b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
index 308d431e6217..a9d3f93af6ac 100644
--- a/drivers/iio/adc/qcom-spmi-adc5-gen3.c
+++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
@@ -21,9 +21,11 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/regmap.h>
+#include <linux/slab.h>
#include <linux/types.h>
#include <linux/unaligned.h>
@@ -597,24 +599,22 @@ static int adc5_get_fw_data(struct adc5_chip *adc)
return 0;
}
-static void adc5_gen3_uninit_aux(void *data)
+static void adc5_gen3_aux_device_release(struct device *dev)
{
- auxiliary_device_uninit(data);
-}
+ struct tm5_aux_dev_wrapper *aux_device =
+ container_of(dev, struct tm5_aux_dev_wrapper, aux_dev.dev);
-static void adc5_gen3_delete_aux(void *data)
-{
- auxiliary_device_delete(data);
+ of_node_put(dev->of_node);
+ kfree(aux_device->tm_props);
+ kfree(aux_device);
}
-static void adc5_gen3_aux_device_release(struct device *dev) {}
-
static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc, int id)
{
struct tm5_aux_dev_wrapper *aux_device;
int i, ret, i_tm = 0;
- aux_device = devm_kzalloc_obj(adc->dev, *aux_device);
+ aux_device = kzalloc_obj(*aux_device);
if (!aux_device)
return -ENOMEM;
@@ -623,11 +623,20 @@ static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc, int id)
aux_device->aux_dev.dev.parent = adc->dev;
aux_device->aux_dev.dev.release = adc5_gen3_aux_device_release;
- aux_device->tm_props = devm_kzalloc_objs(adc->dev,
- *aux_device->tm_props,
- adc->n_tm_channels);
- if (!aux_device->tm_props)
+ ret = auxiliary_device_init(&aux_device->aux_dev);
+ if (ret) {
+ kfree(aux_device);
+ return ret;
+ }
+
+ device_set_of_node_from_dev(&aux_device->aux_dev.dev, adc->dev);
+
+ aux_device->tm_props = kzalloc_objs(*aux_device->tm_props,
+ adc->n_tm_channels);
+ if (!aux_device->tm_props) {
+ auxiliary_device_uninit(&aux_device->aux_dev);
return -ENOMEM;
+ }
aux_device->dev_data = &adc->dev_data;
@@ -638,28 +647,16 @@ static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc, int id)
i_tm++;
}
- device_set_of_node_from_dev(&aux_device->aux_dev.dev, adc->dev);
-
aux_device->n_tm_channels = adc->n_tm_channels;
- ret = auxiliary_device_init(&aux_device->aux_dev);
- if (ret)
- return ret;
-
- ret = devm_add_action_or_reset(adc->dev, adc5_gen3_uninit_aux,
- &aux_device->aux_dev);
- if (ret)
- return ret;
-
ret = auxiliary_device_add(&aux_device->aux_dev);
- if (ret)
- return ret;
- ret = devm_add_action_or_reset(adc->dev, adc5_gen3_delete_aux,
- &aux_device->aux_dev);
- if (ret)
+ if (ret) {
+ auxiliary_device_uninit(&aux_device->aux_dev);
return ret;
+ }
- return 0;
+ return devm_add_action_or_reset(adc->dev, auxiliary_device_destroy,
+ &aux_device->aux_dev);
}
void adc5_gen3_mutex_lock(struct device *dev)
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 2/3] iio: adc: qcom-spmi-adc5-gen3: Reject empty reg property in probe
2026-12-02 20:21 [PATCH v3 0/3] iio: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-02 20:21 ` [PATCH v3 1/3] iio: adc: qcom-spmi-adc5-gen3: Free TM auxiliary device wrapper in release callback Lee Jones
@ 2026-12-02 20:21 ` Lee Jones
2026-12-02 20:21 ` [PATCH v3 3/3] iio: proximity: isl29501: Fix division by zero and overflow in isl29501_set_freq() Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-12-02 20:21 UTC (permalink / raw)
To: lee
Cc: linux-kernel, stable, Nuno Sá, Andy Shevchenko,
David Lechner, Jishnu Prakash, Jonathan Cameron, linux-arm-msm,
linux-iio
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@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
v2 => v3:
- No changes
v1 => v2:
- Return -ENOENT instead of -EINVAL when reg is empty (Andy)
Cc: "Nuno Sá" <nuno.sa@analog.com>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: David Lechner <dlechner@baylibre.com>
Cc: Jishnu Prakash <jishnu.prakash@oss.qualcomm.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-iio@vger.kernel.org
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 a9d3f93af6ac..4c1235de3fe1 100644
--- a/drivers/iio/adc/qcom-spmi-adc5-gen3.c
+++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
@@ -735,6 +735,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.911.g883d8bcb20-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 3/3] iio: proximity: isl29501: Fix division by zero and overflow in isl29501_set_freq()
2026-12-02 20:21 [PATCH v3 0/3] iio: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-02 20:21 ` [PATCH v3 1/3] iio: adc: qcom-spmi-adc5-gen3: Free TM auxiliary device wrapper in release callback Lee Jones
2026-12-02 20:21 ` [PATCH v3 2/3] iio: adc: qcom-spmi-adc5-gen3: Reject empty reg property in probe Lee Jones
@ 2026-12-02 20:21 ` Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2026-12-02 20:21 UTC (permalink / raw)
To: lee
Cc: linux-kernel, stable, Nuno Sá, Andy Shevchenko,
David Lechner, Jonathan Cameron, linux-iio, Mathieu Othacehe
isl29501_set_freq() computes freq = val * 1000000 + val2 % 1000000 in a
signed 32-bit int and passes it directly to do_div() without checking
for zero or negative inputs. Writing 0 to the sampling_frequency
attribute triggers a division by zero in the kernel, while valid
frequencies above 2147 Hz up to the sensor's 2222 Hz limit overflow
signed int.
Validate val and val2 up front so that the requested frequency lies
within (0, 2222] Hz with val2 in [0, MICROHZ_PER_HZ), compute freq as
an unsigned int using MICROHZ_PER_HZ, and return -ERANGE otherwise.
Fixes: 1c28799257bc ("iio: light: isl29501: Add support for the ISL29501 ToF sensor.")
Closes: https://sashiko.dev/#/bug/linux-e4bc1c30-bbf1-458a-99f9-a36e949af67c
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
v2 => v3:
- Fold the zero and upper-bound frequency checks into the initial
validation guard, rejecting val2 >= MICROHZ_PER_HZ, zero frequency,
and values above 2222 Hz (val == 2222 && val2 > 0) before computing
freq without modulo (Andy)
- Use MICROHZ_PER_HZ rather than HZ_PER_MHZ for unit accuracy
v1 => v2:
- Order local variables in reverse Christmas tree style (Andy)
- Group val range checks together (Andy)
- Use units.h multiplier macros (Andy)
Cc: "Nuno Sá" <nuno.sa@analog.com>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: David Lechner <dlechner@baylibre.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org
Cc: Mathieu Othacehe <othacehe@gnu.org>
drivers/iio/proximity/isl29501.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/proximity/isl29501.c b/drivers/iio/proximity/isl29501.c
index a98a9975323c..a61d70db28c4 100644
--- a/drivers/iio/proximity/isl29501.c
+++ b/drivers/iio/proximity/isl29501.c
@@ -18,6 +18,7 @@
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/buffer.h>
#include <linux/iio/triggered_buffer.h>
+#include <linux/units.h>
/* Control, setting and status registers */
#define ISL29501_DEVICE_ID 0x00
@@ -863,12 +864,16 @@ static int isl29501_set_calibbias(struct isl29501_private *isl29501,
static int isl29501_set_freq(struct isl29501_private *isl29501,
int val, int val2)
{
- int freq;
unsigned long long sample_time;
+ unsigned int freq;
+
+ if (val < 0 || val > 2222 || val2 < 0 || val2 >= MICROHZ_PER_HZ ||
+ (val == 0 && val2 == 0) || (val == 2222 && val2 > 0))
+ return -ERANGE;
/* sample_freq = 1 / (0.000450 * (sample_time + 1) * 10^-6) */
- freq = val * 1000000 + val2 % 1000000;
- sample_time = 2222ULL * 1000000ULL;
+ freq = val * MICROHZ_PER_HZ + val2;
+ sample_time = 2222ULL * MICROHZ_PER_HZ;
do_div(sample_time, freq);
sample_time -= 1;
--
2.56.1.911.g883d8bcb20-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-02 20:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 20:21 [PATCH v3 0/3] iio: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-02 20:21 ` [PATCH v3 1/3] iio: adc: qcom-spmi-adc5-gen3: Free TM auxiliary device wrapper in release callback Lee Jones
2026-12-02 20:21 ` [PATCH v3 2/3] iio: adc: qcom-spmi-adc5-gen3: Reject empty reg property in probe Lee Jones
2026-12-02 20:21 ` [PATCH v3 3/3] iio: proximity: isl29501: Fix division by zero and overflow in isl29501_set_freq() Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox