Skip to contentSkip to conversation

mm/z3fold.c: fix lock/unlock imbalance in z3fold_page_isolate

PATCH In review Gustavo A. R. Silva 2 participants 3 messages Aug 26, 2019 – Aug 29, 2019 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/z3fold.c: fix lock/unlock imbalance in z3fold_page_isolate

Fix lock/unlock imbalance by unlocking *zhdr* before return.

Addresses-Coverity-ID: 1452811 ("Missing unlock")

Fixes d776aaa9895e ("mm/z3fold.c: fix race between migration and destruction")
---
 mm/z3fold.c | 1 +
 1 file changed, 1 insertion(+)
mm/z3fold.c +1 -0
index e31cd9bd4ed5..75b7962439ff 100644
@@ -1406,6 +1406,7 @@ static bool z3fold_page_isolate(struct page *page, isolate_mode_t mode)
 				 * should freak out.
 				 */
 				WARN(1, "Z3fold is experiencing kref problems\n");
+				z3fold_page_unlock(zhdr);
 				return false;
 			}
 			z3fold_page_unlock(zhdr);
Signature · 1 line
2.23.0
maintainer
#1 lore raw
Quoted 14 lines · On Sun, 25 Aug 2019 22:06:34 -0500 "Gustavo A. R. Silva"…

Fix lock/unlock imbalance by unlocking *zhdr* before return.

Addresses-Coverity-ID: 1452811 ("Missing unlock")

Fixes d776aaa9895e ("mm/z3fold.c: fix race between migration and destruction")
---
 mm/z3fold.c | 1 +
 1 file changed, 1 insertion(+)
mm/z3fold.c +0 -0
index e31cd9bd4ed5..75b7962439ff 100644

mm/z3fold.c static bool z3fold_page_isolate(struct page *page, isolate_mode_t mode) · line 1412

Quoted 7 lines
mm/z3fold.c +1 -0
@@ -1406,6 +1406,7 @@ static bool z3fold_page_isolate(struct page *page, isolate_mode_t mode)
 				 * should freak out.
 				 */
 				WARN(1, "Z3fold is experiencing kref problems\n");
+				z3fold_page_unlock(zhdr);
 				return false;
 			}
 			z3fold_page_unlock(zhdr);

Looks good, thanks.

This is a bit silly:

			if (..) {
				...
				z3fold_page_unlock(zhdr);
				return false;
			}
			z3fold_page_unlock(zhdr);
			return false;

but presumably the compiler will clean up after us.