[PATCH] Fix the fdtable freeing in the case of vmalloced fdset/arrays
authorDipankar Sarma <dipankar@in.ibm.com>
Wed, 14 Sep 2005 19:18:42 +0000 (00:48 +0530)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 14 Sep 2005 19:38:26 +0000 (12:38 -0700)
Noted by David Miller:

  "The bug is that free_fd_array() takes a "num" argument, but when
   calling it from __free_fdtable() we're instead passing in the size in
   bytes (ie.  "num * sizeof(struct file *)")."

Yes it is a bug. I think I messed it up while merging newer
changes with an older version where I was using size in bytes
to optimize.

Signed-off-by: Dipankar Sarma <dipankar@in.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/file.c

index 2127a7b9dc3a6ad2bb214536bf23e83d5005441b..fd066b261c751875de1c4871974b54d335eafcd7 100644 (file)
--- a/fs/file.c
+++ b/fs/file.c
@@ -69,13 +69,9 @@ void free_fd_array(struct file **array, int num)
 
 static void __free_fdtable(struct fdtable *fdt)
 {
-       int fdset_size, fdarray_size;
-
-       fdset_size = fdt->max_fdset / 8;
-       fdarray_size = fdt->max_fds * sizeof(struct file *);
-       free_fdset(fdt->open_fds, fdset_size);
-       free_fdset(fdt->close_on_exec, fdset_size);
-       free_fd_array(fdt->fd, fdarray_size);
+       free_fdset(fdt->open_fds, fdt->max_fdset);
+       free_fdset(fdt->close_on_exec, fdt->max_fdset);
+       free_fd_array(fdt->fd, fdt->max_fds);
        kfree(fdt);
 }