summaryrefslogtreecommitdiff
path: root/drivers/iio/adc/max1363.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-10-15 08:30:00 (GMT)
committerJonathan Cameron <jic23@kernel.org>2013-10-15 18:19:22 (GMT)
commit0894d80dfddaeb9f95904ceab623460c1bfdab06 (patch)
tree7b482dcaa4b4db142fcabfe866ebe9a7829e7148 /drivers/iio/adc/max1363.c
parentf6c23f483937b8be53f313ec31068acdca91a25d (diff)
downloadlinux-fsl-qoriq-0894d80dfddaeb9f95904ceab623460c1bfdab06.tar.xz
iio:kfifo: Protect against concurrent access from userspace
It is possible for userspace to concurrently access the buffer from multiple threads or processes. To avoid corruption of the internal state of the buffer we need to add proper locking. It is possible for multiple processes to try to read from the buffer concurrently and it is also possible that one process causes a buffer re-allocation while a different process still access the buffer. Both can be fixed by protecting the calls to kfifo_to_user() and kfifo_alloc() by the same mutex. In iio_read_first_n_kfifo() we also use kfifo_recsize() instead of the buffers bytes_per_datum to avoid a race that can happen if bytes_per_datum has been changed, but the buffer has not been reallocated yet. Note that all access to the buffer from within the kernel is already properly synchronized, so there is no need for extra locking in iio_store_to_kfifo(). Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/adc/max1363.c')
0 files changed, 0 insertions, 0 deletions