Skip to content

Commit

Permalink
drm/udl: take reference to device struct for dma-bufs
Browse files Browse the repository at this point in the history
this stops the device from being deleted before all the dma-bufs
on it are freed, this fixes an oops when you unplug a udl device while
it has imported a buffer from another device.

Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Dave Airlie committed Mar 27, 2014
1 parent b098d67 commit 347cf10
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/gpu/drm/udl/udl_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ void udl_gem_free_object(struct drm_gem_object *gem_obj)
if (obj->vmapping)
udl_gem_vunmap(obj);

if (gem_obj->import_attach)
if (gem_obj->import_attach) {
drm_prime_gem_destroy(gem_obj, obj->sg);
put_device(gem_obj->dev->dev);
}

if (obj->pages)
udl_gem_put_pages(obj);
Expand Down Expand Up @@ -256,9 +258,12 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,
int ret;

/* need to attach */
get_device(dev->dev);
attach = dma_buf_attach(dma_buf, dev->dev);
if (IS_ERR(attach))
if (IS_ERR(attach)) {
put_device(dev->dev);
return ERR_CAST(attach);
}

get_dma_buf(dma_buf);

Expand All @@ -282,6 +287,6 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,
fail_detach:
dma_buf_detach(dma_buf, attach);
dma_buf_put(dma_buf);

put_device(dev->dev);
return ERR_PTR(ret);
}

0 comments on commit 347cf10

Please sign in to comment.