From: Joshua Hahn <joshua.hahnjy@gmail.com>
To: Shameer Kolothum <skolothumtho@nvidia.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
muchun.song@linux.dev, osalvador@suse.de,
vivek.kasireddy@intel.com, joshua.hahnjy@gmail.com,
jgg@nvidia.com, nicolinc@nvidia.com, nathanc@nvidia.com,
mochs@nvidia.com
Subject: Re: [PATCH v2] mm/hugetlb: Fix incorrect error return from hugetlb_reserve_pages()
Date: Fri, 24 Oct 2025 07:51:19 -0700 [thread overview]
Message-ID: <20251024145119.2315897-1-joshua.hahnjy@gmail.com> (raw)
In-Reply-To: <20251024094240.337630-1-skolothumtho@nvidia.com>
On Fri, 24 Oct 2025 10:42:40 +0100 Shameer Kolothum <skolothumtho@nvidia.com> wrote:
> The function hugetlb_reserve_pages() returns the number of pages added
> to the reservation map on success and a negative error code on failure
> (e.g. -EINVAL, -ENOMEM). However, in some error paths, it may return -1
> directly.
>
> For example, a failure at:
>
> if (hugetlb_acct_memory(h, gbl_reserve) < 0)
> goto out_put_pages;
>
> results in returning -1 (since add = -1), which may be misinterpreted
> in userspace as -EPERM.
>
> Fix this by explicitly capturing and propagating the return values from
> helper functions, and using -EINVAL for all other failure cases.
>
> Fixes: 986f5f2b4be3 ("mm/hugetlb: make hugetlb_reserve_pages() return nr of entries updated")
> Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com>
> ---
> Addressed commenst from v1. Thanks!
> https://lore.kernel.org/linux-mm/20251022102956.245736-1-skolothumtho@nvidia.com/
> ---
> mm/hugetlb.c | 25 ++++++++++++++++++-------
> 1 file changed, 18 insertions(+), 7 deletions(-)
Hello Shameer, LGTM, thank you for addressing the comments! Feel free to add:
Reviewed-by: Joshua Hahn <joshua.hahnjy@gmail.com>
[...snip...]
> + /* region_chg() above can return -ENOMEM */
> + err = (chg == -ENOMEM) ? -ENOMEM : -EINVAL;
And this looks much more elegant than the version I wrote : -)
next prev parent reply other threads:[~2025-10-24 14:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-24 9:42 Shameer Kolothum
2025-10-24 14:51 ` Joshua Hahn [this message]
2025-11-23 19:40 ` Shameer Kolothum
2025-11-24 19:28 ` Jason Gunthorpe
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=20251024145119.2315897-1-joshua.hahnjy@gmail.com \
--to=joshua.hahnjy@gmail.com \
--cc=jgg@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mochs@nvidia.com \
--cc=muchun.song@linux.dev \
--cc=nathanc@nvidia.com \
--cc=nicolinc@nvidia.com \
--cc=osalvador@suse.de \
--cc=skolothumtho@nvidia.com \
--cc=vivek.kasireddy@intel.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