diff mbox series

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

Message ID 20190826030634.GA4379@embeddedor (mailing list archive)
State New, archived
Headers show
Series mm/z3fold.c: fix lock/unlock imbalance in z3fold_page_isolate | expand

Commit Message

Gustavo A. R. Silva Aug. 26, 2019, 3:06 a.m. UTC
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")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 mm/z3fold.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Andrew Morton Aug. 26, 2019, 11:05 p.m. UTC | #1
On Sun, 25 Aug 2019 22:06:34 -0500 "Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:

> 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")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>  mm/z3fold.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/z3fold.c b/mm/z3fold.c
> index e31cd9bd4ed5..75b7962439ff 100644
> --- a/mm/z3fold.c
> +++ b/mm/z3fold.c
> @@ -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.
Gustavo A. R. Silva Aug. 29, 2019, 7:14 p.m. UTC | #2
On 8/26/19 6:05 PM, Andrew Morton wrote:
> 
> 
> 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.
> 

I agree. I just sent a patch for that:

https://lore.kernel.org/lkml/20190829191312.GA20298@embeddedor/

Thanks
--
Gustavo
diff mbox series

Patch

diff --git a/mm/z3fold.c b/mm/z3fold.c
index e31cd9bd4ed5..75b7962439ff 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -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);