diff options
| author | Dave Airlie <airlied@redhat.com> | 2014-03-25 00:38:44 -0400 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2014-03-26 22:19:50 -0400 |
| commit | 347cf10aed1657a2b385a95f92763a67062c5ad3 (patch) | |
| tree | 0e63e153ca002dc47a37e1505b432ac54038e61e | |
| parent | b098d6726bbfb94c06d6e1097466187afddae61f (diff) | |
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>
| -rw-r--r-- | drivers/gpu/drm/udl/udl_gem.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c index 8d67b943ac05..0394811251bd 100644 --- a/drivers/gpu/drm/udl/udl_gem.c +++ b/drivers/gpu/drm/udl/udl_gem.c | |||
| @@ -177,8 +177,10 @@ void udl_gem_free_object(struct drm_gem_object *gem_obj) | |||
| 177 | if (obj->vmapping) | 177 | if (obj->vmapping) |
| 178 | udl_gem_vunmap(obj); | 178 | udl_gem_vunmap(obj); |
| 179 | 179 | ||
| 180 | if (gem_obj->import_attach) | 180 | if (gem_obj->import_attach) { |
| 181 | drm_prime_gem_destroy(gem_obj, obj->sg); | 181 | drm_prime_gem_destroy(gem_obj, obj->sg); |
| 182 | put_device(gem_obj->dev->dev); | ||
| 183 | } | ||
| 182 | 184 | ||
| 183 | if (obj->pages) | 185 | if (obj->pages) |
| 184 | udl_gem_put_pages(obj); | 186 | udl_gem_put_pages(obj); |
| @@ -256,9 +258,12 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev, | |||
| 256 | int ret; | 258 | int ret; |
| 257 | 259 | ||
| 258 | /* need to attach */ | 260 | /* need to attach */ |
| 261 | get_device(dev->dev); | ||
| 259 | attach = dma_buf_attach(dma_buf, dev->dev); | 262 | attach = dma_buf_attach(dma_buf, dev->dev); |
| 260 | if (IS_ERR(attach)) | 263 | if (IS_ERR(attach)) { |
| 264 | put_device(dev->dev); | ||
| 261 | return ERR_CAST(attach); | 265 | return ERR_CAST(attach); |
| 266 | } | ||
| 262 | 267 | ||
| 263 | get_dma_buf(dma_buf); | 268 | get_dma_buf(dma_buf); |
| 264 | 269 | ||
| @@ -282,6 +287,6 @@ fail_unmap: | |||
| 282 | fail_detach: | 287 | fail_detach: |
| 283 | dma_buf_detach(dma_buf, attach); | 288 | dma_buf_detach(dma_buf, attach); |
| 284 | dma_buf_put(dma_buf); | 289 | dma_buf_put(dma_buf); |
| 285 | 290 | put_device(dev->dev); | |
| 286 | return ERR_PTR(ret); | 291 | return ERR_PTR(ret); |
| 287 | } | 292 | } |
