linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Ken Chen" <kenchen@google.com>
To: Andrew Morton <akpm@linux-foundation.org>, Adam Litke <agl@us.ibm.com>
Cc: linux-mm <linux-mm@kvack.org>
Subject: [patch] fix hugetlbfs quota leak
Date: Thu, 10 Jan 2008 22:24:12 -0800	[thread overview]
Message-ID: <b040c32a0801102224o54da2bfbk4a62b0cfe1d35f37@mail.gmail.com> (raw)

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

Signed-off-by: Ken Chen <kenchen@google.com>

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 7224a4f..b2863f3 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -420,6 +420,8 @@ static struct page *alloc_huge_page_private(struct
vm_area_struct *vma,
 	spin_unlock(&hugetlb_lock);
 	if (!page)
 		page = alloc_buddy_huge_page(vma, addr);
+	if (!page)
+		hugetlb_put_quota(vma->vm_file->f_mapping, 1);
 	return page ? page : ERR_PTR(-VM_FAULT_OOM);
 }

@@ -1206,8 +1208,10 @@ int hugetlb_reserve_pages(struct inode *inode,
long from, long to)
 	if (hugetlb_get_quota(inode->i_mapping, chg))
 		return -ENOSPC;
 	ret = hugetlb_acct_memory(chg);
-	if (ret < 0)
+	if (ret < 0) {
+		hugetlb_put_quota(inode->i_mapping, chg);
 		return ret;
+	}
 	region_add(&inode->i_mapping->private_list, from, to);
 	return 0;
 }

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2008-01-11  6:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-11  6:24 Ken Chen [this message]
2008-01-11  9:44 ` Andrew Morton
2008-01-11 19:03 ` Adam Litke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b040c32a0801102224o54da2bfbk4a62b0cfe1d35f37@mail.gmail.com \
    --to=kenchen@google.com \
    --cc=agl@us.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox