2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-17 09:43:59 +08:00

drm/udl: take reference to device struct for dma-bufs

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>
This commit is contained in:
Dave Airlie 2014-03-25 14:38:44 +10:00
parent b098d6726b
commit 347cf10aed

View File

@ -177,8 +177,10 @@ void udl_gem_free_object(struct drm_gem_object *gem_obj)
if (obj->vmapping) if (obj->vmapping)
udl_gem_vunmap(obj); udl_gem_vunmap(obj);
if (gem_obj->import_attach) if (gem_obj->import_attach) {
drm_prime_gem_destroy(gem_obj, obj->sg); drm_prime_gem_destroy(gem_obj, obj->sg);
put_device(gem_obj->dev->dev);
}
if (obj->pages) if (obj->pages)
udl_gem_put_pages(obj); udl_gem_put_pages(obj);
@ -256,9 +258,12 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,
int ret; int ret;
/* need to attach */ /* need to attach */
get_device(dev->dev);
attach = dma_buf_attach(dma_buf, 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); return ERR_CAST(attach);
}
get_dma_buf(dma_buf); get_dma_buf(dma_buf);
@ -282,6 +287,6 @@ fail_unmap:
fail_detach: fail_detach:
dma_buf_detach(dma_buf, attach); dma_buf_detach(dma_buf, attach);
dma_buf_put(dma_buf); dma_buf_put(dma_buf);
put_device(dev->dev);
return ERR_PTR(ret); return ERR_PTR(ret);
} }