Skip to content

Commit

Permalink
hugetlbfs: add NULL check in hugetlb_zero_setup()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Akinobu Mita authored and Linus Torvalds committed May 7, 2007
1 parent cfce660 commit 5bc9859
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/hugetlbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5bc9859

Please sign in to comment.