Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: ff13be830333 ("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

authored by

Pranjal Ramajor Asha Kanojiya and committed by
Jeffrey Hugo
8d0d16a3 45a3e24f

+2 -2
+2 -2
drivers/accel/qaic/qaic_data.c
··· 23 23 #include <linux/wait.h> 24 24 #include <drm/drm_file.h> 25 25 #include <drm/drm_gem.h> 26 + #include <drm/drm_prime.h> 26 27 #include <drm/drm_print.h> 27 28 #include <uapi/drm/qaic_accel.h> 28 29 ··· 617 616 618 617 if (obj->import_attach) { 619 618 /* DMABUF/PRIME Path */ 620 - dma_buf_detach(obj->import_attach->dmabuf, obj->import_attach); 621 - dma_buf_put(obj->import_attach->dmabuf); 619 + drm_prime_gem_destroy(obj, NULL); 622 620 } else { 623 621 /* Private buffer allocation path */ 624 622 qaic_free_sgt(bo->sgt);