Commit 05c062c3 authored by Ross Lagerwall's avatar Ross Lagerwall Committed by Greg Kroah-Hartman

xen/grant-table: Use put_page instead of free_page

[ Upstream commit 3ac7292a ]

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: default avatarRoss Lagerwall <>
Reviewed-by: default avatarBoris Ostrovsky <>
Signed-off-by: default avatarJuergen Gross <>
Signed-off-by: default avatarSasha Levin <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 70f3461c
......@@ -328,7 +328,7 @@ static void gnttab_handle_deferred(unsigned long unused)
if (entry->page) {
pr_debug("freeing g.e. %#x (pfn %#lx)\n",
entry->ref, page_to_pfn(entry->page));
} else
pr_info("freeing g.e. %#x\n", entry->ref);
......@@ -384,7 +384,7 @@ void gnttab_end_foreign_access(grant_ref_t ref, int readonly,
if (gnttab_end_foreign_access_ref(ref, readonly)) {
if (page != 0)
} else
gnttab_add_deferred(ref, readonly,
page ? virt_to_page(page) : NULL);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment