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-core.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/iio/industrialio-core.c') diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index f939bad31ca..a019a7b424c 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1040,6 +1040,9 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) int __user *ip = (int __user *)arg; int fd; + if (!indio_dev->info) + return -ENODEV; + if (cmd == IIO_GET_EVENT_FD_IOCTL) { fd = iio_event_getfd(indio_dev); if (copy_to_user(ip, &fd, sizeof(fd))) -- cgit v1.2.3-70-g09d2