Commit 90b6f305 authored by Daniel De Graaf's avatar Daniel De Graaf Committed by Konrad Rzeszutek Wilk

xen-gntdev: Fix memory leak when mmap fails

The error path did not decrement the reference count of the grant structure.
Signed-off-by: default avatarDaniel De Graaf <dgdegra@tycho.nsa.gov>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
parent bdc612dc
...@@ -650,15 +650,13 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) ...@@ -650,15 +650,13 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
find_grant_ptes, map); find_grant_ptes, map);
if (err) { if (err) {
printk(KERN_WARNING "find_grant_ptes() failure.\n"); printk(KERN_WARNING "find_grant_ptes() failure.\n");
return err; goto out_put_map;
} }
} }
err = map_grant_pages(map); err = map_grant_pages(map);
if (err) { if (err)
printk(KERN_WARNING "map_grant_pages() failure.\n"); goto out_put_map;
return err;
}
map->is_mapped = 1; map->is_mapped = 1;
...@@ -667,7 +665,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) ...@@ -667,7 +665,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
err = vm_insert_page(vma, vma->vm_start + i*PAGE_SIZE, err = vm_insert_page(vma, vma->vm_start + i*PAGE_SIZE,
map->pages[i]); map->pages[i]);
if (err) if (err)
return err; goto out_put_map;
} }
} }
...@@ -676,6 +674,10 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) ...@@ -676,6 +674,10 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
unlock_out: unlock_out:
spin_unlock(&priv->lock); spin_unlock(&priv->lock);
return err; return err;
out_put_map:
gntdev_put_map(map);
return err;
} }
static const struct file_operations gntdev_fops = { static const struct file_operations gntdev_fops = {
......
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