aboutsummaryrefslogtreecommitdiffstats
path: root/fs/pipe.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-05-06 23:42:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-05-08 13:46:56 -0400
commitba719baeabbff5476eeb91c223e6921ba29e1490 (patch)
treef3023d34b9ca087412839f6b5937478d49e567ec /fs/pipe.c
parentc1236d31a1b9fc018b85e15a3e58e3601ddc90ae (diff)
sys_pipe(): fix file descriptor leaks
Remember to close the files if copy_to_user() failed. Spotted by dm.n9107@gmail.com. Signed-off-by: Ulrich Drepper <drepper@redhat.com> Cc: DM <dm.n9107@gmail.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/pipe.c')
-rw-r--r--fs/pipe.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/pipe.c b/fs/pipe.c
index 3499f9ff6316..ec228bc9f882 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -17,6 +17,7 @@
17#include <linux/highmem.h> 17#include <linux/highmem.h>
18#include <linux/pagemap.h> 18#include <linux/pagemap.h>
19#include <linux/audit.h> 19#include <linux/audit.h>
20#include <linux/syscalls.h>
20 21
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
22#include <asm/ioctls.h> 23#include <asm/ioctls.h>
@@ -1086,8 +1087,11 @@ asmlinkage long __weak sys_pipe(int __user *fildes)
1086 1087
1087 error = do_pipe(fd); 1088 error = do_pipe(fd);
1088 if (!error) { 1089 if (!error) {
1089 if (copy_to_user(fildes, fd, sizeof(fd))) 1090 if (copy_to_user(fildes, fd, sizeof(fd))) {
1091 sys_close(fd[0]);
1092 sys_close(fd[1]);
1090 error = -EFAULT; 1093 error = -EFAULT;
1094 }
1091 } 1095 }
1092 return error; 1096 return error;
1093} 1097}