+ lib-test_hmm-remove-dead-null-checks-after-gfp_nofail-allocations.patch added to mm-nonmm-unstable branch

Andrew Morton <[email protected]> Sat, 25 Jul 2026 20:30:45 -0700
Newsgroups org.kernel.vger.mm-commits
Message-ID <[email protected]>
The patch titled
     Subject: lib/test_hmm: remove dead NULL checks after GFP_NOFAIL allocations
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     lib-test_hmm-remove-dead-null-checks-after-gfp_nofail-allocations.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/lib-test_hmm-remove-dead-null-checks-after-gfp_nofail-allocations.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: Gou Hao <[email protected]>
Subject: lib/test_hmm: remove dead NULL checks after GFP_NOFAIL allocations
Date: Fri, 24 Jul 2026 10:28:50 +0800

kvcalloc with the __GFP_NOFAIL flag will never return NULL, so the
subsequent NULL checks are unreachable dead code.  Remove them.

Link: https://lore.kernel.org/[email protected]
Signed-off-by: Gou Hao <[email protected]>
Cc: Bharat Potnuri <[email protected]>
Cc: Cédric Le Goater <[email protected]>
Cc: Dave Airlie <[email protected]>
Cc: Jason Gunthorpe <[email protected]>
Cc: jiazhenyuan <[email protected]>
Cc: Leon Romanovsky <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Madhavan Srinivasan <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Nam Cao <[email protected]>
Cc: Nicholas Piggin <[email protected]>
Cc: Nilay Shroff <[email protected]>
Cc: Shrikanth Hegde <[email protected]>
Cc: Thomas Zimemrmann <[email protected]>
Cc: Wentao Guan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---

 lib/test_hmm.c |    6 ------
 1 file changed, 6 deletions(-)

--- a/lib/test_hmm.c~lib-test_hmm-remove-dead-null-checks-after-gfp_nofail-allocations
+++ a/lib/test_hmm.c
@@ -1312,16 +1312,10 @@ static int dmirror_migrate_to_device(str
 	if (!mmget_not_zero(mm))
 		return -EINVAL;
 
-	ret = -ENOMEM;
 	src_pfns = kvcalloc(PTRS_PER_PTE, sizeof(*src_pfns),
 			  GFP_KERNEL | __GFP_NOFAIL);
-	if (!src_pfns)
-		goto free_mem;
-
 	dst_pfns = kvcalloc(PTRS_PER_PTE, sizeof(*dst_pfns),
 			  GFP_KERNEL | __GFP_NOFAIL);
-	if (!dst_pfns)
-		goto free_mem;
 
 	ret = 0;
 	mmap_read_lock(mm);
_

Patches currently in -mm which might be from [email protected] are

powerpc-xive-remove-dead-null-check-after-gfp_nofail-allocation.patch
powerpc-xive-add-error-return-value-to-xive_smp_probe.patch
powerpc-xive-fix-use-after-free-of-xive_ipis.patch
drm-remove-dead-warn_on-null-check-after-gfp_nofail-allocation.patch
lib-test_hmm-remove-dead-null-checks-after-gfp_nofail-allocations.patch
rdma-cxgb4-remove-dead-null-checks-after-gfp_nofail-allocations.patch