From f18e7a068a0a31250cdb251810f8f6224931c3f5 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 4 Oct 2013 12:06:00 +0100 Subject: iio: Return -ENODEV for file operations if the device has been unregistered If the IIO device has been unregistered return -ENODEV for any further file operations like read() and ioctl(). This avoids userspace being able to grab new references to the device. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-event.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/iio/industrialio-event.c') diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index 36f0c8e0eb3d..837d450457dd 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c @@ -76,6 +76,9 @@ static unsigned int iio_event_poll(struct file *filep, struct iio_event_interface *ev_int = indio_dev->event_interface; unsigned int events = 0; + if (!indio_dev->info) + return -ENODEV; + poll_wait(filep, &ev_int->wait, wait); spin_lock_irq(&ev_int->wait.lock); @@ -96,6 +99,9 @@ static ssize_t iio_event_chrdev_read(struct file *filep, unsigned int copied; int ret; + if (!indio_dev->info) + return -ENODEV; + if (count < sizeof(struct iio_event_data)) return -EINVAL; -- cgit v1.2.3