mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] lib/test_hmm: fix error path in dmirror_devmem_fault()
@ 2026-05-15  7:03 liuqiangneo
  2026-05-19  0:23 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: liuqiangneo @ 2026-05-15  7:03 UTC (permalink / raw)
  To: akpm, apopple, jgg, leon; +Cc: linux-kernel, linux-mm, Qiang Liu

From: Qiang Liu <liuqiang@kylinos.cn>

Handle migrate_vma_setup() failure via goto err for unified cleanup.

Reviewed-by: Alistair Popple <apopple@nvidia.com>
Signed-off-by: Qiang Liu <liuqiang@kylinos.cn>
---
v2:
- Add comment explaining migrate_vma_setup() won't fail in practice
- https://lore.kernel.org/all/20260514025328.21175-1-liuqiangneo@163.com/
---
 lib/test_hmm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index 213504915737..a232b34f8d3b 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -1679,8 +1679,14 @@ static vm_fault_t dmirror_devmem_fault(struct vm_fault *vmf)
 	if (order)
 		args.flags |= MIGRATE_VMA_SELECT_COMPOUND;
 
-	if (migrate_vma_setup(&args))
-		return VM_FAULT_SIGBUS;
+	/*
+	 * In practice migrate_vma_setup() should never fail unless the
+	 * test is wrong as it just tests some static VMA properties.
+	 */
+	if (migrate_vma_setup(&args)) {
+		ret = VM_FAULT_SIGBUS;
+		goto err;
+	}
 
 	ret = dmirror_devmem_fault_alloc_and_copy(&args, dmirror);
 	if (ret)
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] lib/test_hmm: fix error path in dmirror_devmem_fault()
  2026-05-15  7:03 [PATCH v2] lib/test_hmm: fix error path in dmirror_devmem_fault() liuqiangneo
@ 2026-05-19  0:23 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-05-19  0:23 UTC (permalink / raw)
  To: liuqiangneo; +Cc: apopple, jgg, leon, linux-kernel, linux-mm, Qiang Liu

On Fri, 15 May 2026 15:03:11 +0800 liuqiangneo@163.com wrote:

> From: Qiang Liu <liuqiang@kylinos.cn>
> 
> Handle migrate_vma_setup() failure via goto err for unified cleanup.
> 

Thanks, I'll add this.

Note that AI review might have found some pre-existing issues in the
surrounding code:
	https://sashiko.dev/#/patchset/20260515070312.130435-1-liuqiangneo@163.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-19  0:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-15  7:03 [PATCH v2] lib/test_hmm: fix error path in dmirror_devmem_fault() liuqiangneo
2026-05-19  0:23 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®