Commit 7d8f06ac authored by YoungJun Cho's avatar YoungJun Cho Committed by Dave Airlie

drm/prime: fix to put an exported dma_buf for adding handle failure

When drm_prime_add_buf_handle() returns failure for an exported
dma_buf, the dma_buf was already allocated and its refcount was
increased, so it needs to be put.
Signed-off-by: default avatarYoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: default avatarSeung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 538d6661
...@@ -306,7 +306,7 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev, ...@@ -306,7 +306,7 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
ret = drm_prime_add_buf_handle(&file_priv->prime, ret = drm_prime_add_buf_handle(&file_priv->prime,
obj->export_dma_buf, handle); obj->export_dma_buf, handle);
if (ret) if (ret)
goto out; goto fail_put_dmabuf;
*prime_fd = dma_buf_fd(buf, flags); *prime_fd = dma_buf_fd(buf, flags);
mutex_unlock(&file_priv->prime.lock); mutex_unlock(&file_priv->prime.lock);
...@@ -315,6 +315,12 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev, ...@@ -315,6 +315,12 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
out_have_obj: out_have_obj:
get_dma_buf(dmabuf); get_dma_buf(dmabuf);
*prime_fd = dma_buf_fd(dmabuf, flags); *prime_fd = dma_buf_fd(dmabuf, flags);
goto out;
fail_put_dmabuf:
/* clear NOT to be checked when releasing dma_buf */
obj->export_dma_buf = NULL;
dma_buf_put(buf);
out: out:
drm_gem_object_unreference_unlocked(obj); drm_gem_object_unreference_unlocked(obj);
mutex_unlock(&file_priv->prime.lock); mutex_unlock(&file_priv->prime.lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment