fix cdev leak on O_PATH final fput()
authorMiklos Szeredi <miklos@szeredi.hu>
Wed, 16 Mar 2011 17:17:54 +0000 (18:17 +0100)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 16 Mar 2011 20:18:39 +0000 (16:18 -0400)
__fput doesn't need a cdev_put() for O_PATH handles.

Signed-off-by: mszeredi@suse.cz
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/file_table.c

index 74a9544ac770a9870e9efb4d489fbe41394934e7..db30d3497f1a45534a42962b6a22173e16f24e04 100644 (file)
@@ -246,8 +246,10 @@ static void __fput(struct file *file)
                file->f_op->release(inode, file);
        security_file_free(file);
        ima_file_free(file);
-       if (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL))
+       if (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL &&
+                    !(file->f_mode & FMODE_PATH))) {
                cdev_put(inode->i_cdev);
+       }
        fops_put(file->f_op);
        put_pid(file->f_owner.pid);
        file_sb_list_del(file);