Commit 39ed3fdeec1290dd246dcf1da6b278566987a084
Committed by
Linus Torvalds
1 parent
580b2e3c01
Exists in
master
and in
7 other branches
[PATCH] futex: remove duplicate code
This patch cleans up the error path of futex_fd() by removing duplicate code. Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 9 additions and 12 deletions Side-by-side Diff
kernel/futex.c
... | ... | @@ -786,23 +786,17 @@ |
786 | 786 | filp->f_mapping = filp->f_dentry->d_inode->i_mapping; |
787 | 787 | |
788 | 788 | if (signal) { |
789 | - int err; | |
790 | 789 | err = f_setown(filp, current->pid, 1); |
791 | 790 | if (err < 0) { |
792 | - put_unused_fd(ret); | |
793 | - put_filp(filp); | |
794 | - ret = err; | |
795 | - goto out; | |
791 | + goto error; | |
796 | 792 | } |
797 | 793 | filp->f_owner.signum = signal; |
798 | 794 | } |
799 | 795 | |
800 | 796 | q = kmalloc(sizeof(*q), GFP_KERNEL); |
801 | 797 | if (!q) { |
802 | - put_unused_fd(ret); | |
803 | - put_filp(filp); | |
804 | - ret = -ENOMEM; | |
805 | - goto out; | |
798 | + err = -ENOMEM; | |
799 | + goto error; | |
806 | 800 | } |
807 | 801 | |
808 | 802 | down_read(¤t->mm->mmap_sem); |
809 | 803 | |
... | ... | @@ -810,10 +804,8 @@ |
810 | 804 | |
811 | 805 | if (unlikely(err != 0)) { |
812 | 806 | up_read(¤t->mm->mmap_sem); |
813 | - put_unused_fd(ret); | |
814 | - put_filp(filp); | |
815 | 807 | kfree(q); |
816 | - return err; | |
808 | + goto error; | |
817 | 809 | } |
818 | 810 | |
819 | 811 | /* |
... | ... | @@ -829,6 +821,11 @@ |
829 | 821 | fd_install(ret, filp); |
830 | 822 | out: |
831 | 823 | return ret; |
824 | +error: | |
825 | + put_unused_fd(ret); | |
826 | + put_filp(filp); | |
827 | + ret = err; | |
828 | + goto out; | |
832 | 829 | } |
833 | 830 | |
834 | 831 | long do_futex(unsigned long uaddr, int op, int val, unsigned long timeout, |