iio: chemical: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 13 Apr 2025 10:34:35 +0000 (11:34 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 21 May 2025 13:20:26 +0000 (14:20 +0100)
This new function allows us to perform debug checks in the helper to ensure
that the overrun does not occur.  Use it in all the simple cases where
either a static buffer or a structure is used in the drivers.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250413103443.2420727-13-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/chemical/atlas-sensor.c
drivers/iio/chemical/bme680_core.c
drivers/iio/chemical/ccs811.c
drivers/iio/chemical/ens160_core.c
drivers/iio/chemical/pms7003.c
drivers/iio/chemical/scd30_core.c
drivers/iio/chemical/scd4x.c
drivers/iio/chemical/sps30.c

index bde473f9483fbf7c10c028685b01c2f45d3a02ef..cb6662b9213740f4a88b8412e6a0f01bc5a314d6 100644 (file)
@@ -458,8 +458,9 @@ static irqreturn_t atlas_trigger_handler(int irq, void *private)
                              &data->buffer, sizeof(__be32) * channels);
 
        if (!ret)
-               iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
-                               iio_get_time_ns(indio_dev));
+               iio_push_to_buffers_with_ts(indio_dev, data->buffer,
+                                           sizeof(data->buffer),
+                                           iio_get_time_ns(indio_dev));
 
        iio_trigger_notify_done(indio_dev->trig);
 
index 9d73fd2cf52cbf4a6e48a8109c1a4c729fbf6c60..3e850562ab001f3ef7415d69c4fd3b7adb9ab32f 100644 (file)
@@ -1120,8 +1120,8 @@ static irqreturn_t bme680_trigger_handler(int irq, void *p)
        gas_range = FIELD_GET(BME680_GAS_RANGE_MASK, gas_regs_val);
        data->scan.chan[3] = bme680_compensate_gas(data, adc_gas_res, gas_range);
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
-                                          iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan),
+                                   iio_get_time_ns(indio_dev));
 out:
        iio_trigger_notify_done(indio_dev->trig);
        return IRQ_HANDLED;
index 1eab256a1e00585094cf75fd33bf69411dca526a..998c9239c4c7f4832c5120f58fae2431622a99eb 100644 (file)
@@ -343,8 +343,8 @@ static irqreturn_t ccs811_trigger_handler(int irq, void *p)
                goto err;
        }
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
-                                          iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan),
+                                   iio_get_time_ns(indio_dev));
 
 err:
        iio_trigger_notify_done(indio_dev->trig);
index 152f81ff57e31223e5c446e4f3c5947d4decea79..6cec600748272dbfa1772dc25536722907d08e37 100644 (file)
@@ -267,8 +267,8 @@ static irqreturn_t ens160_trigger_handler(int irq, void *p)
        if (ret)
                goto err;
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
-                                          pf->timestamp);
+       iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan),
+                                   pf->timestamp);
 err:
        iio_trigger_notify_done(indio_dev->trig);
 
index d0bd94912e0a3492641acd955adbc2184f4a11b3..93075f604555c9a1d054810fd2ce12ea08568d17 100644 (file)
@@ -126,8 +126,8 @@ static irqreturn_t pms7003_trigger_handler(int irq, void *p)
                pms7003_get_pm(frame->data + PMS7003_PM10_OFFSET);
        mutex_unlock(&state->lock);
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &state->scan,
-                                          iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &state->scan, sizeof(state->scan),
+                                   iio_get_time_ns(indio_dev));
 err:
        iio_trigger_notify_done(indio_dev->trig);
 
index 3fed6b63710f0c57591e33dd43dfb1762301dff4..8316720b1fa32b9746b4aeefe7aedc77b3ba57e6 100644 (file)
@@ -601,7 +601,8 @@ static irqreturn_t scd30_trigger_handler(int irq, void *p)
        if (ret)
                goto out;
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+                                   iio_get_time_ns(indio_dev));
 out:
        iio_trigger_notify_done(indio_dev->trig);
        return IRQ_HANDLED;
index 4877bd3e907bb5ae9d7e3167d7b8b321e108bff7..2463149519b6d82caede9c9b253942fa421fdd3c 100644 (file)
@@ -675,7 +675,8 @@ static irqreturn_t scd4x_trigger_handler(int irq, void *p)
        if (ret)
                goto out;
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+                                   iio_get_time_ns(indio_dev));
 out:
        iio_trigger_notify_done(indio_dev->trig);
        return IRQ_HANDLED;
index 6f4f2ba2c09d5e691df13bc11ca9e3a910d98dc8..2554ef74e141794536e8129de07ac87d84a4a38e 100644 (file)
@@ -117,8 +117,8 @@ static irqreturn_t sps30_trigger_handler(int irq, void *p)
        if (ret)
                goto err;
 
-       iio_push_to_buffers_with_timestamp(indio_dev, &scan,
-                                          iio_get_time_ns(indio_dev));
+       iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
+                                   iio_get_time_ns(indio_dev));
 err:
        iio_trigger_notify_done(indio_dev->trig);