dma_unmap_sg(attachment->dev, sg->sgl, sg->nents, dir);
        sg_free_table(sg);
        kfree(sg);
+ 
+       i915_gem_object_unpin_pages(obj);
+ 
+       mutex_unlock(&obj->base.dev->struct_mutex);
  }
  
 -static void i915_gem_dmabuf_release(struct dma_buf *dma_buf)
 -{
 -      struct drm_i915_gem_object *obj = dma_buf->priv;
 -
 -      if (obj->base.export_dma_buf == dma_buf) {
 -              /* drop the reference on the export fd holds */
 -              obj->base.export_dma_buf = NULL;
 -              drm_gem_object_unreference_unlocked(&obj->base);
 -      }
 -}
 -
  static void *i915_gem_dmabuf_vmap(struct dma_buf *dma_buf)
  {
-       struct drm_i915_gem_object *obj = dma_buf->priv;
+       struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf);
        struct drm_device *dev = obj->base.dev;
        struct sg_page_iter sg_iter;
        struct page **pages;