From: Akinobu Mita Date: Sun, 6 May 2007 21:50:18 +0000 (-0700) Subject: hugetlbfs: add NULL check in hugetlb_zero_setup() X-Git-Tag: firefly_0821_release~30073 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5bc98594d59672303c4c9c07262ecc373dc374da;p=firefly-linux-kernel-4.4.55.git hugetlbfs: add NULL check in hugetlb_zero_setup() 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 Acked-by: William Irwin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 842a4ed4052d..98959b87cdf8 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -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);