diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2011-09-21 11:16:02 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-09-26 17:31:56 -0700 |
commit | 30eb82f05dd1f12b18a0ad054401a0b5690fb3c3 (patch) | |
tree | 2970468c533272e6d840fb42ab3aff0636655040 /drivers/staging/iio/industrialio-buffer.c | |
parent | ad31d250bf60c8e4c990e8b0daeedbaa2d6884a9 (diff) | |
download | op-kernel-dev-30eb82f05dd1f12b18a0ad054401a0b5690fb3c3.zip op-kernel-dev-30eb82f05dd1f12b18a0ad054401a0b5690fb3c3.tar.gz |
staging:iio: Prevent reading from buffer chrdev when device has no buffer.
Silly bug introduced during the chrdev merge series.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/iio/industrialio-buffer.c')
-rw-r--r-- | drivers/staging/iio/industrialio-buffer.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/staging/iio/industrialio-buffer.c b/drivers/staging/iio/industrialio-buffer.c index c3f57e7..4ce101a 100644 --- a/drivers/staging/iio/industrialio-buffer.c +++ b/drivers/staging/iio/industrialio-buffer.c @@ -63,11 +63,14 @@ unsigned int iio_buffer_poll(struct file *filp, return 0; } -void iio_chrdev_buffer_open(struct iio_dev *indio_dev) +int iio_chrdev_buffer_open(struct iio_dev *indio_dev) { struct iio_buffer *rb = indio_dev->buffer; - if (rb && rb->access->mark_in_use) + if (!rb) + return -EINVAL; + if (rb->access->mark_in_use) rb->access->mark_in_use(rb); + return 0; } void iio_chrdev_buffer_release(struct iio_dev *indio_dev) @@ -77,7 +80,6 @@ void iio_chrdev_buffer_release(struct iio_dev *indio_dev) clear_bit(IIO_BUSY_BIT_POS, &rb->flags); if (rb->access->unmark_in_use) rb->access->unmark_in_use(rb); - } void iio_buffer_init(struct iio_buffer *buffer, struct iio_dev *dev_info) |