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 <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Suggested-by: Christian König <[email protected]> Signed-off-by: Pranjal Ramajor Asha Kanojiya <[email protected]> Reviewed-by: Carl Vanderlip <[email protected]> Reviewed-by: Jeffrey Hugo <[email protected]> Signed-off-by: Jeffrey Hugo <[email protected]> Reviewed-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
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)