This is a note to let you know that I've just added the patch titled

    ramfs: fix memleak on no-mmu arch

to the 2.6.38-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ramfs-fix-memleak-on-no-mmu-arch.patch
and it can be found in the queue-2.6.38 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From b836aec53e2bce71de1d5415313380688c851477 Mon Sep 17 00:00:00 2001
From: Bob Liu <[email protected]>
Date: Thu, 14 Apr 2011 15:22:20 -0700
Subject: ramfs: fix memleak on no-mmu arch

From: Bob Liu <[email protected]>

commit b836aec53e2bce71de1d5415313380688c851477 upstream.

On no-mmu arch, there is a memleak during shmem test.  The cause of this
memleak is ramfs_nommu_expand_for_mapping() added page refcount to 2
which makes iput() can't free that pages.

The simple test file is like this:

  int main(void)
  {
        int i;
        key_t k = ftok("/etc", 42);

        for ( i=0; i<100; ++i) {
                int id = shmget(k, 10000, 0644|IPC_CREAT);
                if (id == -1) {
                        printf("shmget error\n");
                }
                if(shmctl(id, IPC_RMID, NULL ) == -1) {
                        printf("shm  rm error\n");
                        return -1;
                }
        }
        printf("run ok...\n");
        return 0;
  }

And the result:

  root:/> free
               total         used         free       shared      buffers
  Mem:         60320        17912        42408            0            0
  -/+ buffers:              17912        42408
  root:/> shmem
  run ok...
  root:/> free
               total         used         free       shared      buffers
  Mem:         60320        19096        41224            0            0
  -/+ buffers:              19096        41224
  root:/> shmem
  run ok...
  root:/> free
               total         used         free       shared      buffers
  Mem:         60320        20296        40024            0            0
  -/+ buffers:              20296        40024
  ...

After this patch the test result is:(no memleak anymore)

  root:/> free
               total         used         free       shared      buffers
  Mem:         60320        16668        43652            0            0
  -/+ buffers:              16668        43652
  root:/> shmem
  run ok...
  root:/> free
               total         used         free       shared      buffers
  Mem:         60320        16668        43652            0            0
  -/+ buffers:              16668        43652

Signed-off-by: Bob Liu <[email protected]>
Acked-by: Hugh Dickins <[email protected]>
Signed-off-by: David Howells <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 fs/ramfs/file-nommu.c |    1 +
 1 file changed, 1 insertion(+)

--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -112,6 +112,7 @@ int ramfs_nommu_expand_for_mapping(struc
                SetPageDirty(page);
 
                unlock_page(page);
+               put_page(page);
        }
 
        return 0;


Patches currently in stable-queue which might be from [email protected] are

queue-2.6.38/ramfs-fix-memleak-on-no-mmu-arch.patch

_______________________________________________
stable mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/stable

Reply via email to