Rafael Aquini f70d7e4675 mm/hugetlb: fix incorrect error return from hugetlb_reserve_pages()
JIRA: https://redhat.atlassian.net/browse/RHEL-145695

commit 9ee5d1766c8bfa4924bd47e31c4dd193493f5a45
Author: Shameer Kolothum <skolothumtho@nvidia.com>
Date:   Tue Nov 25 17:13:50 2025 +0000

    mm/hugetlb: fix incorrect error return from hugetlb_reserve_pages()

    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.

    Link: https://lkml.kernel.org/r/20251125171350.86441-1-skolothumtho@nvidia.com
    Fixes: 986f5f2b4be3 ("mm/hugetlb: make hugetlb_reserve_pages() return nr of entries updated")
    Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com>
    Reviewed-by: Joshua Hahn <joshua.hahnjy@gmail.com>
    Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
    Acked-by: Oscar Salvador <osalvador@suse.de>
    Cc: Matthew R. Ochs <mochs@nvidia.com>
    Cc: Muchun Song <muchun.song@linux.dev>
    Cc: Nicolin Chen <nicolinc@nvidia.com>
    Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Signed-off-by: Rafael Aquini <raquini@redhat.com>
2026-07-31 14:51:07 -04:00
2026-07-31 14:50:55 -04:00
2026-07-01 16:15:37 -04:00
2026-01-19 14:33:01 -05:00
2026-07-01 16:16:28 -04:00

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the reStructuredText markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.
S
Description
No description provided
Readme
2.8 GiB
Languages
C 97.5%
Assembly 1%
Shell 0.6%
Python 0.3%
Makefile 0.3%