The error path did not decrement the reference count of the grant structure.
Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
                                          find_grant_ptes, map);
                if (err) {
                        printk(KERN_WARNING "find_grant_ptes() failure.\n");
-                       return err;
+                       goto out_put_map;
                }
        }
 
        err = map_grant_pages(map);
-       if (err) {
-               printk(KERN_WARNING "map_grant_pages() failure.\n");
-               return err;
-       }
+       if (err)
+               goto out_put_map;
 
        map->is_mapped = 1;
 
                        err = vm_insert_page(vma, vma->vm_start + i*PAGE_SIZE,
                                map->pages[i]);
                        if (err)
-                               return err;
+                               goto out_put_map;
                }
        }
 
 unlock_out:
        spin_unlock(&priv->lock);
        return err;
+
+out_put_map:
+       gntdev_put_map(map);
+       return err;
 }
 
 static const struct file_operations gntdev_fops = {