summaryrefslogtreecommitdiff
path: root/mm/memfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memfd.c')
-rw-r--r--mm/memfd.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/mm/memfd.c b/mm/memfd.c
index 0e3ff3eebfa8..05088ab210ba 100644
--- a/mm/memfd.c
+++ b/mm/memfd.c
@@ -32,6 +32,13 @@
static bool memfd_folio_has_extra_refs(struct folio *folio)
{
+ /*
+ * Use the precise pincount where available to avoid racy refcount
+ * comparisons.
+ */
+ if (folio_has_pincount(folio) && folio_maybe_dma_pinned(folio))
+ return true;
+
return folio_ref_count(folio) != folio_expected_ref_count(folio);
}