From: Mike Kravetz <mike.kravetz@oracle.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
Mina Almasry <almasrymina@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Rientjes <rientjes@google.com>,
linux-mm@kvack.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] hugetlb: Fix an error code in hugetlb_reserve_pages()
Date: Mon, 14 Dec 2020 11:27:50 -0800 [thread overview]
Message-ID: <dff4211a-687c-a3e1-fdf6-1562581e0da4@oracle.com> (raw)
In-Reply-To: <X9NGZWnZl5/Mt99R@mwanda>
On 12/11/20 2:13 AM, Dan Carpenter wrote:
> Preserve the error code from region_add() instead of returning success.
>
> Fixes: 0db9d74ed884 ("hugetlb: disable region_add file_region coalescing")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> From static analysis. Untested.
Thanks Dan.
>
> mm/hugetlb.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 1f3bf1710b66..ac2e48b9f1d7 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5113,6 +5113,7 @@ int hugetlb_reserve_pages(struct inode *inode,
>
> if (unlikely(add < 0)) {
> hugetlb_acct_memory(h, -gbl_reserve);
> + ret = add;
> goto out_put_pages;
> } else if (unlikely(chg > add)) {
> /*
>
That error path is VERY unlikely to be taken, but is indeed incorrect.
When looking at this, I noticed that callers of hugetlb_reserve_pages only
check for 0 or !0. This changed as the code evolved to add reservation
cgroup support. The routine type can be changed to a bool and simplified
some. I'll send that as a follow up patch not for stable.
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
--
Mike Kravetz
prev parent reply other threads:[~2020-12-14 19:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-11 10:13 [PATCH] hugetlb: Fix an error code in hugetlb_reserve_pages() Dan Carpenter
2020-12-11 19:49 ` Souptick Joarder
2020-12-11 21:45 ` Matthew Wilcox
2020-12-14 6:30 ` Dan Carpenter
2020-12-14 9:37 ` David Hildenbrand
2020-12-14 19:27 ` Mike Kravetz [this message]
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=dff4211a-687c-a3e1-fdf6-1562581e0da4@oracle.com \
--to=mike.kravetz@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=almasrymina@google.com \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
/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;
as well as URLs for NNTP newsgroup(s).