Re: Memory leak in 2.3.43pre2 (select.c changes)

From: Manfred Spraul (manfreds@colorfullife.com)
Date: Tue Feb 08 2000 - 03:32:14 EST


Simon Kirby wrote:
>
> There's a memory leak in 2.3.43pre2 that showed visibly about 10 seconds
> after starting X (I could see sawmill draw the window borders and
> netscape felt slow),

Yes, that was my patch. I merged another patch without single stepping
it, and that patch removed required variables. Please apply the attached
patch on top of 2.3.43-2.

Sorry,
        Manfred

--- 2.3/fs/select.c Tue Feb 8 09:22:19 2000
+++ build-2.3/fs/select.c Tue Feb 8 09:15:24 2000
@@ -173,11 +173,11 @@
 
 int do_select(int n, fd_set_bits *fds, long *timeout)
 {
- poll_table *wait;
+ poll_table *wait_table, *wait;
         int retval, i, off;
         long __timeout = *timeout;
 
- wait = NULL;
+ wait_table = wait = NULL;
 
          read_lock(&current->files->file_lock);
         retval = max_select_fd(n, fds);
@@ -190,6 +190,7 @@
                  wait = alloc_wait(n);
                  if (!wait)
                         return -ENOMEM;
+ wait_table = wait;
          }
         retval = 0;
         for (;;) {
@@ -235,7 +236,8 @@
         }
         current->state = TASK_RUNNING;
 
- free_wait(wait);
+ if(wait_table)
+ free_wait(wait_table);
 
         /*
          * Up-to-date the caller timeout.
@@ -406,7 +408,7 @@
 {
         int i, j, fdcount, err;
         struct pollfd **fds;
- poll_table *wait = NULL;
+ poll_table *wait_table, *wait;
         int nchunks, nleft;
 
         /* Do a sanity check on nfds ... */
@@ -421,10 +423,12 @@
                         timeout = MAX_SCHEDULE_TIMEOUT;
         }
 
+ wait = wait_table = NULL;
         if (timeout) {
                 wait = alloc_wait(nfds);
                 if (!wait)
                         return -ENOMEM;
+ wait_table = wait;
         }
         err = -ENOMEM;
 
@@ -487,6 +491,7 @@
         if (nfds != 0)
                 kfree(fds);
 out:
- free_wait(wait);
+ if(wait_table)
+ free_wait(wait_table);
         return err;
 }

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Feb 15 2000 - 21:00:12 EST