diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-11-21 17:25:37 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-11-21 17:25:37 -0500 |
commit | b46413367961c2e8bd827e067a231be982aaeee2 (patch) | |
tree | 8f3249e7cc9d85ea3c36cdbd2c77729aa34627e9 | |
parent | c332c10c01d8d31f2eba9abc04b0fc3d62610ed8 (diff) | |
download | linux-stable-b46413367961c2e8bd827e067a231be982aaeee2.tar.gz linux-stable-b46413367961c2e8bd827e067a231be982aaeee2.tar.bz2 linux-stable-b46413367961c2e8bd827e067a231be982aaeee2.zip |
iio: fix a leak due to improper use of anon_inode_getfd()
it can fail and in that case ->release() will *not* be called...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | drivers/staging/iio/industrialio-core.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 326e967d54ef..26564094e33b 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -242,6 +242,8 @@ static const struct file_operations iio_event_chrdev_fileops = { static int iio_event_getfd(struct iio_dev *indio_dev) { + int fd; + if (indio_dev->event_interface == NULL) return -ENODEV; @@ -252,9 +254,15 @@ static int iio_event_getfd(struct iio_dev *indio_dev) return -EBUSY; } mutex_unlock(&indio_dev->event_interface->event_list_lock); - return anon_inode_getfd("iio:event", + fd = anon_inode_getfd("iio:event", &iio_event_chrdev_fileops, indio_dev->event_interface, O_RDONLY); + if (fd < 0) { + mutex_lock(&indio_dev->event_interface->event_list_lock); + clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); + mutex_unlock(&indio_dev->event_interface->event_list_lock); + } + return fd; } static int __init iio_init(void) |