mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
iio: proximity: Use iio_push_to_buffers_with_ts() to provide length for runtime checks.
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-18-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
175c3f7215
commit
fc11c42dd1
|
|
@ -231,8 +231,8 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private)
|
|||
goto err_read;
|
||||
|
||||
st->scan.chan = val & AS3935_DATA_MASK;
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, &st->scan,
|
||||
iio_get_time_ns(indio_dev));
|
||||
iio_push_to_buffers_with_ts(indio_dev, &st->scan, sizeof(st->scan),
|
||||
iio_get_time_ns(indio_dev));
|
||||
err_read:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
||||
|
|
|
|||
|
|
@ -953,8 +953,8 @@ static irqreturn_t hx9023s_trigger_handler(int irq, void *private)
|
|||
data->buffer.channels[i++] = cpu_to_le16(data->ch_data[index].diff);
|
||||
}
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer,
|
||||
pf->timestamp);
|
||||
iio_push_to_buffers_with_ts(indio_dev, &data->buffer,
|
||||
sizeof(data->buffer), pf->timestamp);
|
||||
|
||||
out:
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
|
|
|
|||
|
|
@ -125,8 +125,8 @@ static irqreturn_t mb1232_trigger_handler(int irq, void *p)
|
|||
if (data->scan.distance < 0)
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -238,8 +238,9 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private)
|
|||
|
||||
ret = lidar_get_measurement(data, &data->scan.chan);
|
||||
if (!ret) {
|
||||
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));
|
||||
} else if (ret != -EINVAL) {
|
||||
dev_err(&data->client->dev, "cannot read LIDAR measurement");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,8 +191,8 @@ static irqreturn_t srf08_trigger_handler(int irq, void *p)
|
|||
mutex_lock(&data->lock);
|
||||
|
||||
data->scan.chan = sensor_data;
|
||||
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);
|
||||
|
||||
mutex_unlock(&data->lock);
|
||||
err:
|
||||
|
|
|
|||
|
|
@ -379,8 +379,8 @@ static irqreturn_t sx_common_trigger_handler(int irq, void *private)
|
|||
data->buffer.channels[i++] = val;
|
||||
}
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer,
|
||||
pf->timestamp);
|
||||
iio_push_to_buffers_with_ts(indio_dev, &data->buffer,
|
||||
sizeof(data->buffer), pf->timestamp);
|
||||
|
||||
out:
|
||||
mutex_unlock(&data->mutex);
|
||||
|
|
|
|||
|
|
@ -94,8 +94,8 @@ static irqreturn_t vl53l0x_trigger_handler(int irq, void *priv)
|
|||
return -EREMOTEIO;
|
||||
|
||||
data->scan.chan = get_unaligned_be16(&buffer[10]);
|
||||
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));
|
||||
|
||||
iio_trigger_notify_done(indio_dev->trig);
|
||||
vl53l0x_clear_irq(data);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user