Skip to content

Commit 8d0d16a

Browse files
Pranjal Ramajor Asha Kanojiyaquic-jhugo
authored andcommitted
accel/qaic: Call DRM helper function to destroy prime GEM
smatch warning: drivers/accel/qaic/qaic_data.c:620 qaic_free_object() error: dereferencing freed memory 'obj->import_attach' obj->import_attach is detached and freed using dma_buf_detach(). But used after free to decrease the dmabuf ref count using dma_buf_put(). drm_prime_gem_destroy() handles this issue and performs the proper clean up instead of open coding it in the driver. Fixes: ff13be8 ("accel/qaic: Add datapath") Reported-by: Sukrut Bellary <sukrut.bellary@linux.com> Closes: https://lore.kernel.org/all/20230610021200.377452-1-sukrut.bellary@linux.com/ Suggested-by: Christian König <christian.koenig@amd.com> Signed-off-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com> Reviewed-by: Carl Vanderlip <quic_carlv@quicinc.com> Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com> Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com> Reviewed-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230614161528.11710-1-quic_jhugo@quicinc.com
1 parent 45a3e24 commit 8d0d16a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/accel/qaic/qaic_data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/wait.h>
2424
#include <drm/drm_file.h>
2525
#include <drm/drm_gem.h>
26+
#include <drm/drm_prime.h>
2627
#include <drm/drm_print.h>
2728
#include <uapi/drm/qaic_accel.h>
2829

@@ -616,8 +617,7 @@ static void qaic_free_object(struct drm_gem_object *obj)
616617

617618
if (obj->import_attach) {
618619
/* DMABUF/PRIME Path */
619-
dma_buf_detach(obj->import_attach->dmabuf, obj->import_attach);
620-
dma_buf_put(obj->import_attach->dmabuf);
620+
drm_prime_gem_destroy(obj, NULL);
621621
} else {
622622
/* Private buffer allocation path */
623623
qaic_free_sgt(bo->sgt);

0 commit comments

Comments
 (0)