Skip to content

Commit 23cc663

Browse files
rosslagerwallZhengShunQian
authored andcommitted
xen/grant-table: Use put_page instead of free_page
[ Upstream commit 3ac7292 ] 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]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e82cdad commit 23cc663

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/xen/grant-table.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static void gnttab_handle_deferred(unsigned long unused)
328328
if (entry->page) {
329329
pr_debug("freeing g.e. %#x (pfn %#lx)\n",
330330
entry->ref, page_to_pfn(entry->page));
331-
__free_page(entry->page);
331+
put_page(entry->page);
332332
} else
333333
pr_info("freeing g.e. %#x\n", entry->ref);
334334
kfree(entry);
@@ -384,7 +384,7 @@ void gnttab_end_foreign_access(grant_ref_t ref, int readonly,
384384
if (gnttab_end_foreign_access_ref(ref, readonly)) {
385385
put_free_entry(ref);
386386
if (page != 0)
387-
free_page(page);
387+
put_page(virt_to_page(page));
388388
} else
389389
gnttab_add_deferred(ref, readonly,
390390
page ? virt_to_page(page) : NULL);

0 commit comments

Comments
 (0)