[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251024145119.2315897-1-joshua.hahnjy@gmail.com>
Date: Fri, 24 Oct 2025 07:51:19 -0700
From: Joshua Hahn <joshua.hahnjy@...il.com>
To: Shameer Kolothum <skolothumtho@...dia.com>
Cc: linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
muchun.song@...ux.dev,
osalvador@...e.de,
vivek.kasireddy@...el.com,
joshua.hahnjy@...il.com,
jgg@...dia.com,
nicolinc@...dia.com,
nathanc@...dia.com,
mochs@...dia.com
Subject: Re: [PATCH v2] mm/hugetlb: Fix incorrect error return from hugetlb_reserve_pages()
On Fri, 24 Oct 2025 10:42:40 +0100 Shameer Kolothum <skolothumtho@...dia.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@...dia.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@...il.com>
[...snip...]
> + /* region_chg() above can return -ENOMEM */
> + err = (chg == -ENOMEM) ? -ENOMEM : -EINVAL;
And this looks much more elegant than the version I wrote : -)
Powered by blists - more mailing lists