Commit e38c79e0 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Greg Kroah-Hartman

staging:iio: Disallow modifying buffer size when buffer is enabled

The buffer buffer storage is only update when enabling the buffer. Changing the
buffer size while the buffer is enabled will confuse the buffer in regard to
its actual buffer size and can cause potential memory corruption. Thus it is
only safe to modify the buffer size when the buffer is disabled.
Acked-by: default avatarJonathan Cameron <jic23@kernel.org>
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 5fd6218c
......@@ -396,13 +396,20 @@ ssize_t iio_buffer_write_length(struct device *dev,
if (val == buffer->access->get_length(buffer))
return len;
if (buffer->access->set_length) {
buffer->access->set_length(buffer, val);
if (buffer->access->mark_param_change)
buffer->access->mark_param_change(buffer);
mutex_lock(&indio_dev->mlock);
if (iio_buffer_enabled(indio_dev)) {
ret = -EBUSY;
} else {
if (buffer->access->set_length) {
buffer->access->set_length(buffer, val);
if (buffer->access->mark_param_change)
buffer->access->mark_param_change(buffer);
}
ret = 0;
}
mutex_unlock(&indio_dev->mlock);
return len;
return ret ? ret : len;
}
EXPORT_SYMBOL(iio_buffer_write_length);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment