Skip to content

Commit 3ac7292

Browse files
rosslagerwalljgross1
authored andcommitted
xen/grant-table: Use put_page instead of free_page
The page given to gnttab_end_foreign_access() to free could be a compound page so use put_page() instead of free_page() since it can handle both compound and single pages correctly. This bug was discovered when migrating a Xen VM with several VIFs and CONFIG_DEBUG_VM enabled. It hits a BUG usually after fewer than 10 iterations. All netfront devices disconnect from the backend during a suspend/resume and this will call gnttab_end_foreign_access() if a netfront queue has an outstanding skb. The mismatch between calling get_page() and free_page() on a compound page causes a reference counting error which is detected when DEBUG_VM is enabled. Signed-off-by: Ross Lagerwall <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent 4f27729 commit 3ac7292

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/xen/grant-table.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ static void gnttab_handle_deferred(struct timer_list *unused)
382382
if (entry->page) {
383383
pr_debug("freeing g.e. %#x (pfn %#lx)\n",
384384
entry->ref, page_to_pfn(entry->page));
385-
__free_page(entry->page);
385+
put_page(entry->page);
386386
} else
387387
pr_info("freeing g.e. %#x\n", entry->ref);
388388
kfree(entry);
@@ -438,7 +438,7 @@ void gnttab_end_foreign_access(grant_ref_t ref, int readonly,
438438
if (gnttab_end_foreign_access_ref(ref, readonly)) {
439439
put_free_entry(ref);
440440
if (page != 0)
441-
free_page(page);
441+
put_page(virt_to_page(page));
442442
} else
443443
gnttab_add_deferred(ref, readonly,
444444
page ? virt_to_page(page) : NULL);

0 commit comments

Comments
 (0)