Commit 96b7e579addd3cdc806c1667bf5b6b126070827c
1 parent
e45198a6ac
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
switch do_dentry_open() to returning int
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 1 changed file with 20 additions and 20 deletions Side-by-side Diff
fs/open.c
... | ... | @@ -667,10 +667,10 @@ |
667 | 667 | return 0; |
668 | 668 | } |
669 | 669 | |
670 | -static struct file *do_dentry_open(struct dentry *dentry, struct vfsmount *mnt, | |
671 | - struct file *f, | |
672 | - int (*open)(struct inode *, struct file *), | |
673 | - const struct cred *cred) | |
670 | +static int do_dentry_open(struct dentry *dentry, struct vfsmount *mnt, | |
671 | + struct file *f, | |
672 | + int (*open)(struct inode *, struct file *), | |
673 | + const struct cred *cred) | |
674 | 674 | { |
675 | 675 | static const struct file_operations empty_fops = {}; |
676 | 676 | struct inode *inode; |
... | ... | @@ -699,7 +699,7 @@ |
699 | 699 | |
700 | 700 | if (unlikely(f->f_mode & FMODE_PATH)) { |
701 | 701 | f->f_op = &empty_fops; |
702 | - return f; | |
702 | + return 0; | |
703 | 703 | } |
704 | 704 | |
705 | 705 | f->f_op = fops_get(inode->i_fop); |
... | ... | @@ -726,7 +726,7 @@ |
726 | 726 | |
727 | 727 | file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping); |
728 | 728 | |
729 | - return f; | |
729 | + return 0; | |
730 | 730 | |
731 | 731 | cleanup_all: |
732 | 732 | fops_put(f->f_op); |
... | ... | @@ -749,7 +749,7 @@ |
749 | 749 | cleanup_file: |
750 | 750 | dput(dentry); |
751 | 751 | mntput(mnt); |
752 | - return ERR_PTR(error); | |
752 | + return error; | |
753 | 753 | } |
754 | 754 | |
755 | 755 | static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, |
756 | 756 | |
757 | 757 | |
758 | 758 | |
759 | 759 | |
... | ... | @@ -757,17 +757,19 @@ |
757 | 757 | int (*open)(struct inode *, struct file *), |
758 | 758 | const struct cred *cred) |
759 | 759 | { |
760 | - struct file *res = do_dentry_open(dentry, mnt, f, open, cred); | |
761 | - if (!IS_ERR(res)) { | |
762 | - int error = open_check_o_direct(f); | |
760 | + int error; | |
761 | + error = do_dentry_open(dentry, mnt, f, open, cred); | |
762 | + if (!error) { | |
763 | + error = open_check_o_direct(f); | |
763 | 764 | if (error) { |
764 | - fput(res); | |
765 | - res = ERR_PTR(error); | |
765 | + fput(f); | |
766 | + f = ERR_PTR(error); | |
766 | 767 | } |
767 | - } else { | |
768 | + } else { | |
768 | 769 | put_filp(f); |
770 | + f = ERR_PTR(error); | |
769 | 771 | } |
770 | - return res; | |
772 | + return f; | |
771 | 773 | } |
772 | 774 | |
773 | 775 | /** |
774 | 776 | |
775 | 777 | |
776 | 778 | |
... | ... | @@ -785,19 +787,17 @@ |
785 | 787 | int (*open)(struct inode *, struct file *), |
786 | 788 | int *opened) |
787 | 789 | { |
788 | - struct file *res; | |
790 | + int error; | |
789 | 791 | BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */ |
790 | 792 | |
791 | 793 | mntget(file->f_path.mnt); |
792 | 794 | dget(dentry); |
793 | 795 | |
794 | - res = do_dentry_open(dentry, file->f_path.mnt, file, open, current_cred()); | |
795 | - if (!IS_ERR(res)) { | |
796 | + error = do_dentry_open(dentry, file->f_path.mnt, file, open, current_cred()); | |
797 | + if (!error) | |
796 | 798 | *opened |= FILE_OPENED; |
797 | - return 0; | |
798 | - } | |
799 | 799 | |
800 | - return PTR_ERR(res); | |
800 | + return error; | |
801 | 801 | } |
802 | 802 | EXPORT_SYMBOL(finish_open); |
803 | 803 |