2020-05-09 03:01:12

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next] mm/hmm/test: fix missing unlock on error in dmirror_migrate_finalize_and_map()

Add the missing unlock before return from function
dmirror_migrate_finalize_and_map() in the error
handling case.

Fixes: 5d5e54be8a1e ("mm/hmm/test: add selftest driver for HMM")
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Wei Yongjun <[email protected]>
---
lib/test_hmm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index 00bca6116f93..30462193c4ff 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -647,8 +647,10 @@ static int dmirror_migrate_finalize_and_map(struct migrate_vma *args,
if (*dst & MIGRATE_PFN_WRITE)
entry = xa_tag_pointer(entry, DPT_XA_TAG_WRITE);
entry = xa_store(&dmirror->pt, pfn, entry, GFP_ATOMIC);
- if (xa_is_err(entry))
+ if (xa_is_err(entry)) {
+ mutex_unlock(&dmirror->mutex);
return xa_err(entry);
+ }
}

mutex_unlock(&dmirror->mutex);




2020-05-11 17:25:04

by Ralph Campbell

[permalink] [raw]
Subject: Re: [PATCH -next] mm/hmm/test: fix missing unlock on error in dmirror_migrate_finalize_and_map()


On 5/8/20 8:02 PM, Wei Yongjun wrote:
> Add the missing unlock before return from function
> dmirror_migrate_finalize_and_map() in the error
> handling case.
>
> Fixes: 5d5e54be8a1e ("mm/hmm/test: add selftest driver for HMM")
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Wei Yongjun <[email protected]>

Looks good, thanks!
Reviewed-by: Ralph Campbell <[email protected]>

> ---
> lib/test_hmm.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/test_hmm.c b/lib/test_hmm.c
> index 00bca6116f93..30462193c4ff 100644
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -647,8 +647,10 @@ static int dmirror_migrate_finalize_and_map(struct migrate_vma *args,
> if (*dst & MIGRATE_PFN_WRITE)
> entry = xa_tag_pointer(entry, DPT_XA_TAG_WRITE);
> entry = xa_store(&dmirror->pt, pfn, entry, GFP_ATOMIC);
> - if (xa_is_err(entry))
> + if (xa_is_err(entry)) {
> + mutex_unlock(&dmirror->mutex);
> return xa_err(entry);
> + }
> }
>
> mutex_unlock(&dmirror->mutex);
>
>
>
>

2020-05-12 20:04:25

by Jason Gunthorpe

[permalink] [raw]
Subject: Re: [PATCH -next] mm/hmm/test: fix missing unlock on error in dmirror_migrate_finalize_and_map()

On Sat, May 09, 2020 at 03:02:25AM +0000, Wei Yongjun wrote:
> Add the missing unlock before return from function
> dmirror_migrate_finalize_and_map() in the error
> handling case.
>
> Fixes: 5d5e54be8a1e ("mm/hmm/test: add selftest driver for HMM")
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Wei Yongjun <[email protected]>
> ---
> lib/test_hmm.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)

Thank you, I squashed this into the original commit

Jason