Commit a45a6dde authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] O_DIRECT open() fix

Trivial bugfix: opening a file that doesn't have ->direct_IO() with
O_DIRECT passed in flags fails (as it should) but doesn't call
->release() even though ->open() had been successful.

IOW, we have a leak there - e.g.  open() of a tty with O_DIRECT will
leak a reference to tty and tty_driver.  Besides, quite a few drivers
are _not_ happy with struct file being freed without ->release() after
->open() has returned 0.
parent 2d9318a1
...@@ -671,8 +671,8 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) ...@@ -671,8 +671,8 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
if (f->f_flags & O_DIRECT) { if (f->f_flags & O_DIRECT) {
if (!inode->i_mapping || !inode->i_mapping->a_ops || if (!inode->i_mapping || !inode->i_mapping->a_ops ||
!inode->i_mapping->a_ops->direct_IO) { !inode->i_mapping->a_ops->direct_IO) {
error = -EINVAL; fput(f);
goto cleanup_all; f = ERR_PTR(-EINVAL);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment