]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/memfd_luo: remove unnecessary memset in zero-size memfd path
authorChenghao Duan <duanchenghao@kylinos.cn>
Thu, 26 Mar 2026 08:47:23 +0000 (16:47 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 18 Apr 2026 07:10:52 +0000 (00:10 -0700)
The memset(kho_vmalloc, 0, sizeof(*kho_vmalloc)) call in the zero-size
file handling path is unnecessary because the allocation of the ser
structure already uses the __GFP_ZERO flag, ensuring the memory is already
zero-initialized.

Link: https://lore.kernel.org/20260326084727.118437-4-duanchenghao@kylinos.cn
Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Haoran Jiang <jianghaoran@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memfd_luo.c

index 865b044bee62bf1b3e6b7871854dfb70e5821973..5a8ead5be08790a4b7cf47f9fad92c91cf1f4947 100644 (file)
@@ -105,7 +105,6 @@ static int memfd_luo_preserve_folios(struct file *file,
        if (!size) {
                *nr_foliosp = 0;
                *out_folios_ser = NULL;
-               memset(kho_vmalloc, 0, sizeof(*kho_vmalloc));
                return 0;
        }