Skip to content

Commit

Permalink
fix cdev leak on O_PATH final fput()
Browse files Browse the repository at this point in the history
__fput doesn't need a cdev_put() for O_PATH handles.

Signed-off-by: [email protected]
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
szmi authored and Al Viro committed Mar 16, 2011
1 parent bab1d94 commit 60ed8cf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/file_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 60ed8cf

Please sign in to comment.