Skip to content

Commit

Permalink
xen/gntdev: Fix partial gntdev_mmap() cleanup
Browse files Browse the repository at this point in the history
When cleaning up after a partially successful gntdev_mmap(), unmap the
successfully mapped grant pages otherwise Xen will kill the domain if
in debug mode (Attempt to implicitly unmap a granted PTE) or Linux will
kill the process and emit "BUG: Bad page map in process" if Xen is in
release mode.

This is only needed when use_ptemod is true because gntdev_put_map()
will unmap grant pages itself when use_ptemod is false.

Signed-off-by: Ross Lagerwall <[email protected]>
Reviewed-by: Boris Ostrovsky <[email protected]>
Signed-off-by: Boris Ostrovsky <[email protected]>
  • Loading branch information
rosslagerwall authored and Boris Ostrovsky committed Jan 10, 2018
1 parent 951a010 commit cf2acf6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/xen/gntdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,10 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
out_unlock_put:
mutex_unlock(&priv->lock);
out_put_map:
if (use_ptemod)
if (use_ptemod) {
map->vma = NULL;
unmap_grant_pages(map, 0, map->count);
}
gntdev_put_map(priv, map);
return err;
}
Expand Down

0 comments on commit cf2acf6

Please sign in to comment.