xen-gntdev: Use map->vma for checking map validity
The is_mapped flag used to be set at the completion of the map operation, but was not checked in all error paths. Use map->vma instead, which will now be cleared if the initial grant mapping fails. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
This commit is contained in:
parent
0ea22f072f
commit
84e4075d60
|
@ -77,7 +77,6 @@ struct grant_map {
|
||||||
int index;
|
int index;
|
||||||
int count;
|
int count;
|
||||||
int flags;
|
int flags;
|
||||||
int is_mapped;
|
|
||||||
atomic_t users;
|
atomic_t users;
|
||||||
struct unmap_notify notify;
|
struct unmap_notify notify;
|
||||||
struct ioctl_gntdev_grant_ref *grants;
|
struct ioctl_gntdev_grant_ref *grants;
|
||||||
|
@ -322,7 +321,6 @@ static void gntdev_vma_close(struct vm_area_struct *vma)
|
||||||
struct grant_map *map = vma->vm_private_data;
|
struct grant_map *map = vma->vm_private_data;
|
||||||
|
|
||||||
pr_debug("close %p\n", vma);
|
pr_debug("close %p\n", vma);
|
||||||
map->is_mapped = 0;
|
|
||||||
map->vma = NULL;
|
map->vma = NULL;
|
||||||
vma->vm_private_data = NULL;
|
vma->vm_private_data = NULL;
|
||||||
gntdev_put_map(map);
|
gntdev_put_map(map);
|
||||||
|
@ -347,8 +345,6 @@ static void mn_invl_range_start(struct mmu_notifier *mn,
|
||||||
list_for_each_entry(map, &priv->maps, next) {
|
list_for_each_entry(map, &priv->maps, next) {
|
||||||
if (!map->vma)
|
if (!map->vma)
|
||||||
continue;
|
continue;
|
||||||
if (!map->is_mapped)
|
|
||||||
continue;
|
|
||||||
if (map->vma->vm_start >= end)
|
if (map->vma->vm_start >= end)
|
||||||
continue;
|
continue;
|
||||||
if (map->vma->vm_end <= start)
|
if (map->vma->vm_end <= start)
|
||||||
|
@ -663,8 +659,6 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
|
||||||
if (err)
|
if (err)
|
||||||
goto out_put_map;
|
goto out_put_map;
|
||||||
|
|
||||||
map->is_mapped = 1;
|
|
||||||
|
|
||||||
if (!use_ptemod) {
|
if (!use_ptemod) {
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
err = vm_insert_page(vma, vma->vm_start + i*PAGE_SIZE,
|
err = vm_insert_page(vma, vma->vm_start + i*PAGE_SIZE,
|
||||||
|
@ -681,6 +675,8 @@ unlock_out:
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
out_put_map:
|
out_put_map:
|
||||||
|
if (use_ptemod)
|
||||||
|
map->vma = NULL;
|
||||||
gntdev_put_map(map);
|
gntdev_put_map(map);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue