Skip to contentSkip to conversation

mm/hmm/test: fix missing unlock on error in dmirror_migrate_finalize_and_map()

PATCH In review Wei Yongjun 3 participants 3 messages May 9, 2020 – May 12, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 lib/test_hmm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/test_hmm.c +3 -1
index 00bca6116f93..30462193c4ff 100644
@@ -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);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Wei Yongjun

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")

Looks good, thanks!

Quoted 24 lines
---
  lib/test_hmm.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
lib/test_hmm.c +3 -1
index 00bca6116f93..30462193c4ff 100644
@@ -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);
#2 lore raw
In reply to Wei Yongjun
Quoted 10 lines · Wei Yongjun

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")
---
 lib/test_hmm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Thank you, I squashed this into the original commit

Jason