From 0a29c633adc329ea30364806aab0a2d8b799b549 Mon Sep 17 00:00:00 2001 From: Marian Ohligs Date: Wed, 12 Sep 2012 15:42:07 +0200 Subject: [PATCH] remove memory leak --- kernel/syscall.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/syscall.c b/kernel/syscall.c index f0f5521f..7dfee0c4 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -352,6 +352,13 @@ static int sys_dup(int fd) if (BUILTIN_EXPECT((new_fd >= NR_OPEN) || (fd < 0), 0)) return new_fd; /* in this case fd = errno */ + /* + * free the memory which was allocated in get_fildes() + * cause will link it to another existing memory space + */ + kfree(curr_task->fildes_table[new_fd], sizeof(fildes_t)); + + /* and link it to another existing memory space */ curr_task->fildes_table[new_fd] = curr_task->fildes_table[fd]; curr_task->fildes_table[fd]->count++;