Skip to contentSkip to conversation

mm-zone_device-do-not-touch-device-folio-after-calling-folio_free.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 1 participant 1 message Apr 19 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled

     Subject: mm/zone_device: do not touch device folio after calling ->folio_free()

has been removed from the -mm tree. Its filename was
mm-zone_device-do-not-touch-device-folio-after-calling-folio_free.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Matthew Brost <[email protected]>
Subject: mm/zone_device: do not touch device folio after calling ->folio_free()
Date: Fri, 10 Apr 2026 16:03:46 -0700

The contents of a device folio can immediately change after calling ->folio_free(), as the folio may be reallocated by a driver with a different order. Instead of touching the folio again to extract the pgmap, use the local stack variable when calling percpu_ref_put_many().

Fixes d245f9b4ab80 ("mm/zone_device: support large zone device private folios")
Cc David Hildenbrand <[email protected]>
Cc Oscar Salvador <[email protected]>

---

 mm/memremap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memremap.c renamed from mm/memremap.c~mm-zone_device-do-not-touch-device-folio-after-calling-folio_free +1 -1
@@ -454,7 +454,7 @@ void free_zone_device_folio(struct folio
 		if (WARN_ON_ONCE(!pgmap->ops || !pgmap->ops->folio_free))
 			break;
 		pgmap->ops->folio_free(folio);
-		percpu_ref_put_many(&folio->pgmap->ref, nr);
+		percpu_ref_put_many(&pgmap->ref, nr);
 		break;
 
 	case MEMORY_DEVICE_GENERIC:

_

Patches currently in -mm which might be from [email protected] are