Commit 39ed3fde authored by Pekka Enberg's avatar Pekka Enberg Committed by Linus Torvalds

[PATCH] futex: remove duplicate code

This patch cleans up the error path of futex_fd() by removing duplicate
code.
Signed-off-by: default avatarPekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 580b2e3c
...@@ -786,23 +786,17 @@ static int futex_fd(unsigned long uaddr, int signal) ...@@ -786,23 +786,17 @@ static int futex_fd(unsigned long uaddr, int signal)
filp->f_mapping = filp->f_dentry->d_inode->i_mapping; filp->f_mapping = filp->f_dentry->d_inode->i_mapping;
if (signal) { if (signal) {
int err;
err = f_setown(filp, current->pid, 1); err = f_setown(filp, current->pid, 1);
if (err < 0) { if (err < 0) {
put_unused_fd(ret); goto error;
put_filp(filp);
ret = err;
goto out;
} }
filp->f_owner.signum = signal; filp->f_owner.signum = signal;
} }
q = kmalloc(sizeof(*q), GFP_KERNEL); q = kmalloc(sizeof(*q), GFP_KERNEL);
if (!q) { if (!q) {
put_unused_fd(ret); err = -ENOMEM;
put_filp(filp); goto error;
ret = -ENOMEM;
goto out;
} }
down_read(&current->mm->mmap_sem); down_read(&current->mm->mmap_sem);
...@@ -810,10 +804,8 @@ static int futex_fd(unsigned long uaddr, int signal) ...@@ -810,10 +804,8 @@ static int futex_fd(unsigned long uaddr, int signal)
if (unlikely(err != 0)) { if (unlikely(err != 0)) {
up_read(&current->mm->mmap_sem); up_read(&current->mm->mmap_sem);
put_unused_fd(ret);
put_filp(filp);
kfree(q); kfree(q);
return err; goto error;
} }
/* /*
...@@ -829,6 +821,11 @@ static int futex_fd(unsigned long uaddr, int signal) ...@@ -829,6 +821,11 @@ static int futex_fd(unsigned long uaddr, int signal)
fd_install(ret, filp); fd_install(ret, filp);
out: out:
return ret; return ret;
error:
put_unused_fd(ret);
put_filp(filp);
ret = err;
goto out;
} }
long do_futex(unsigned long uaddr, int op, int val, unsigned long timeout, long do_futex(unsigned long uaddr, int op, int val, unsigned long timeout,
......
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