Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

hugetlbfs: fix quota leak

In the error path of both shared and private hugetlb page allocation,
the file system quota is never undone, leading to fs quota leak. Fix
them up.

[akpm@linux-foundation.org: cleanup, micro-optimise]
Signed-off-by: Ken Chen <kenchen@google.com>
Acked-by: Adam Litke <agl@us.ibm.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: William Lee Irwin III <wli@holomorphy.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ken Chen and committed by
Linus Torvalds
68842c9b 747d016e

+10 -3
+10 -3
mm/hugetlb.c
··· 418 418 if (free_huge_pages > resv_huge_pages) 419 419 page = dequeue_huge_page(vma, addr); 420 420 spin_unlock(&hugetlb_lock); 421 - if (!page) 421 + if (!page) { 422 422 page = alloc_buddy_huge_page(vma, addr); 423 - return page ? page : ERR_PTR(-VM_FAULT_OOM); 423 + if (!page) { 424 + hugetlb_put_quota(vma->vm_file->f_mapping, 1); 425 + return ERR_PTR(-VM_FAULT_OOM); 426 + } 427 + } 428 + return page; 424 429 } 425 430 426 431 static struct page *alloc_huge_page(struct vm_area_struct *vma, ··· 1211 1206 if (hugetlb_get_quota(inode->i_mapping, chg)) 1212 1207 return -ENOSPC; 1213 1208 ret = hugetlb_acct_memory(chg); 1214 - if (ret < 0) 1209 + if (ret < 0) { 1210 + hugetlb_put_quota(inode->i_mapping, chg); 1215 1211 return ret; 1212 + } 1216 1213 region_add(&inode->i_mapping->private_list, from, to); 1217 1214 return 0; 1218 1215 }