• Greg Thelen's avatar
    tmpfs: fix mempolicy object leaks · 49cd0a5c
    Greg Thelen authored
    Fix several mempolicy leaks in the tmpfs mount logic.  These leaks are
    slow - on the order of one object leaked per mount attempt.
    
    Leak 1 (umount doesn't free mpol allocated in mount):
        while true; do
            mount -t tmpfs -o mpol=interleave,size=100M nodev /mnt
            umount /mnt
        done
    
    Leak 2 (errors parsing remount options will leak mpol):
        mount -t tmpfs -o size=100M nodev /mnt
        while true; do
            mount -o remount,mpol=interleave,size=x /mnt 2> /dev/null
        done
        umount /mnt
    
    Leak 3 (multiple mpol per mount leak mpol):
        while true; do
            mount -t tmpfs -o mpol=interleave,mpol=interleave,size=100M nodev /mnt
            umount /mnt
        done
    
    This patch fixes all of the above.  I could have broken the patch into
    three pieces but is seemed easier to review as one.
    
    [akpm@linux-foundation.org: fix handling of mpol_parse_str() errors, per Hugh]
    Signed-off-by: default avatarGreg Thelen <gthelen@google.com>
    Acked-by: default avatarHugh Dickins <hughd@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    49cd0a5c
shmem.c 76.9 KB