Skip to content

Commit

Permalink
mm/damon/paddr: fix folio_size() call after folio_put() in damon_pa_y…
Browse files Browse the repository at this point in the history
…oung()

Patch series "mm/damon/paddr: Fix folio-use-after-put bugs".

There are two folio accesses after folio_put() in mm/damon/paddr.c file. 
Fix those.


This patch (of 2):

damon_pa_young() is accessing a folio via folio_size() after folio_put()
for the folio has invoked.  Fix it.

Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Fixes: 397b0c3 ("mm/damon/paddr: remove folio_sz field from damon_pa_access_chk_result")
Signed-off-by: SeongJae Park <[email protected]>
Reviewed-by: Kefeng Wang <[email protected]>
Reviewed-by: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vishal Moola (Oracle) <[email protected]>
Cc: <[email protected]>	[6.2.x]
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
sjp38 authored and akpm00 committed Mar 8, 2023
1 parent 90410bc commit 751688b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions mm/damon/paddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz)
accessed = false;
else
accessed = true;
folio_put(folio);
goto out;
}

Expand All @@ -144,10 +143,10 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz)

if (need_lock)
folio_unlock(folio);
folio_put(folio);

out:
*folio_sz = folio_size(folio);
folio_put(folio);
return accessed;
}

Expand Down

0 comments on commit 751688b

Please sign in to comment.