devpts: plug the memory leak in kill_sb
authorIlija Hadzic <ihadzic@research.bell-labs.com>
Tue, 12 Nov 2013 23:11:45 +0000 (15:11 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 13 Nov 2013 03:09:36 +0000 (12:09 +0900)
When devpts is unmounted, there may be a no-longer-used IDR tree hanging
off the superblock we are about to kill.  This needs to be cleaned up
before destroying the SB.

The leak is usually not a big deal because unmounting devpts is typically
done when shutting down the whole machine.  However, shutting down an LXC
container instead of a physical machine exposes the problem (the garbage
is detectable with kmemleak).

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/devpts/inode.c

index 073d30b..a726b9f 100644 (file)
@@ -498,6 +498,7 @@ static void devpts_kill_sb(struct super_block *sb)
 {
        struct pts_fs_info *fsi = DEVPTS_SB(sb);
 
+       ida_destroy(&fsi->allocated_ptys);
        kfree(fsi);
        kill_litter_super(sb);
 }