lkml.org 
[lkml]   [2021]   [Dec]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] drm/i915/selftests: fix potential refcnt issue of a dma_buf object
Date
This issue happens in an error path of igt_dmabuf_export_vmap(). When
dma_buf_vmap() succeeds and memchr_inv() returns nonzero, the function
forgets to decrement `vmapping_counter` of the dma_buf object, which
may result in refcount leaks.

Fix it by calling dma_buf_vunmap() under label `out_dma_map` in
certain error path.

Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
---
drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
index 4a6bb64c3..b24bc506f 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
@@ -428,12 +428,14 @@ static int igt_dmabuf_export_vmap(void *arg)
if (memchr_inv(ptr, 0, dmabuf->size)) {
pr_err("Exported object not initialiased to zero!\n");
err = -EINVAL;
- goto out;
+ goto out_dma_map;
}

memset(ptr, 0xc5, dmabuf->size);

err = 0;
+
+out_dma_map:
dma_buf_vunmap(dmabuf, &map);
out:
dma_buf_put(dmabuf);
--
2.25.1
\
 
 \ /
  Last update: 2021-12-23 04:43    [W:0.023 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site