hugetlbfs: add NULL check in hugetlb_zero_setup()
authorAkinobu Mita <akinobu.mita@gmail.com>
Sun, 6 May 2007 21:50:18 +0000 (14:50 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 7 May 2007 19:12:57 +0000 (12:12 -0700)
If hugetlbfs module_init() fails, hugetlbfs_vfsmount is not initialized and
shmget() with SHM_HUGETLB flag will cause NULL pointer dereference.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: William Irwin <wli@holomorphy.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/hugetlbfs/inode.c

index 842a4ed4052d1d2039684b2bd0fefefa4bb70f32..98959b87cdf8f1f674c668673b10bf110a7bf653 100644 (file)
@@ -747,6 +747,9 @@ struct file *hugetlb_zero_setup(size_t size)
        char buf[16];
        static atomic_t counter;
 
+       if (!hugetlbfs_vfsmount)
+               return ERR_PTR(-ENOENT);
+
        if (!can_do_hugetlb_shm())
                return ERR_PTR(-EPERM);