Re: [PATCH] lib/test_hmm: fix error path in dmirror_devmem_fault()
From: Alistair Popple
Date: Fri May 15 2026 - 01:56:09 EST
On 2026-05-14 at 12:53 +1000, liuqiangneo@xxxxxxx wrote...
> From: Qiang Liu <liuqiang@xxxxxxxxxx>
>
> Handle migrate_vma_setup() failure via goto err for unified cleanup.
In practice migrate_vma_setup() should never fail unless the test is wrong as it
just tests some static VMA properties. It might be nice to add a comment to that
effect, but the fix looks good so feel free to add:
Reviewed-by: Alistair Popple <apopple@xxxxxxxxxx>
- Alistair
> Signed-off-by: Qiang Liu <liuqiang@xxxxxxxxxx>
> ---
> lib/test_hmm.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/test_hmm.c b/lib/test_hmm.c
> index 213504915737..5430ef97bbe0 100644
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -1679,8 +1679,10 @@ 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;
> + 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
>
>