Thread (7 messages) flat view 7 messages, 2 authors, 2026-07-23
COLD45d

[PATCH 3/4] lib/test_hmm: remove dead NULL checks after GFP_NOFAIL allocations

From: Gou Hao <hidden>
Date: 2026-07-23 08:18:58
Also in: linux-mm, linux-rdma, lkml
Subsystem: hmm - heterogeneous memory management, library code, the rest · Maintainers: Jason Gunthorpe, Leon Romanovsky, Andrew Morton, Linus Torvalds

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

Signed-off-by: Gou Hao <redacted>
---
 lib/test_hmm.c | 6 ------
 1 file changed, 6 deletions(-)
diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index 9c59d1ceb5b5..d615e4e5fc44 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -1209,16 +1209,10 @@ static int dmirror_migrate_to_device(struct dmirror *dmirror,
 	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);
-- 
2.20.1

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help