diff options
-rw-r--r-- | fs/anon_inodes.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c index c16d9be1b017..3bbdb9d02376 100644 --- a/fs/anon_inodes.c +++ b/fs/anon_inodes.c | |||
@@ -79,9 +79,12 @@ int anon_inode_getfd(const char *name, const struct file_operations *fops, | |||
79 | if (IS_ERR(anon_inode_inode)) | 79 | if (IS_ERR(anon_inode_inode)) |
80 | return -ENODEV; | 80 | return -ENODEV; |
81 | 81 | ||
82 | if (fops->owner && !try_module_get(fops->owner)) | ||
83 | return -ENOENT; | ||
84 | |||
82 | error = get_unused_fd_flags(flags); | 85 | error = get_unused_fd_flags(flags); |
83 | if (error < 0) | 86 | if (error < 0) |
84 | return error; | 87 | goto err_module; |
85 | fd = error; | 88 | fd = error; |
86 | 89 | ||
87 | /* | 90 | /* |
@@ -128,6 +131,8 @@ err_dput: | |||
128 | dput(dentry); | 131 | dput(dentry); |
129 | err_put_unused_fd: | 132 | err_put_unused_fd: |
130 | put_unused_fd(fd); | 133 | put_unused_fd(fd); |
134 | err_module: | ||
135 | module_put(fops->owner); | ||
131 | return error; | 136 | return error; |
132 | } | 137 | } |
133 | EXPORT_SYMBOL_GPL(anon_inode_getfd); | 138 | EXPORT_SYMBOL_GPL(anon_inode_getfd); |