Skip to content

Commit 3992898

Browse files
mbrost05akpm00
authored andcommitted
mm/zone_device: do not touch device folio after calling ->folio_free()
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(). Link: https://lore.kernel.org/20260410230346.4009855-1-matthew.brost@intel.com Fixes: d245f9b ("mm/zone_device: support large zone device private folios") Signed-off-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Balbir Singh <balbirs@nvidia.com> Reviewed-by: Vishal Moola <vishal.moola@gmail.com> Reviewed-by: Alistair Popple <apopple@nvidia.com> Cc: David Hildenbrand <david@kernel.org> Cc: Oscar Salvador <osalvador@suse.de> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 8bbde98 commit 3992898

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

mm/memremap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ void free_zone_device_folio(struct folio *folio)
454454
if (WARN_ON_ONCE(!pgmap->ops || !pgmap->ops->folio_free))
455455
break;
456456
pgmap->ops->folio_free(folio);
457-
percpu_ref_put_many(&folio->pgmap->ref, nr);
457+
percpu_ref_put_many(&pgmap->ref, nr);
458458
break;
459459

460460
case MEMORY_DEVICE_GENERIC:

0 commit comments

Comments
 (0)