[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211223033948.5208-1-xiongx18@fudan.edu.cn>
Date: Thu, 23 Dec 2021 11:39:49 +0800
From: Xin Xiong <xiongx18@...an.edu.cn>
To: Jani Nikula <jani.nikula@...ux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
Sumit Semwal <sumit.semwal@...aro.org>,
Christian König <christian.koenig@....com>,
intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
linaro-mm-sig@...ts.linaro.org
Cc: yuanxzhang@...an.edu.cn, Xin Xiong <xiongx18@...an.edu.cn>,
Xiyu Yang <xiyuyang19@...an.edu.cn>,
Xin Tan <tanxin.ctf@...il.com>
Subject: [PATCH] drm/i915/selftests: fix potential refcnt issue of a dma_buf object
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@...an.edu.cn>
Signed-off-by: Xiyu Yang <xiyuyang19@...an.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@...il.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
Powered by blists - more mailing lists