Re: [PATCH] accel/qaic: Call DRM helper function to destroy prime GEM

From: Jeffrey Hugo
Date: Thu Jun 15 2023 - 11:23:24 EST


On 6/15/2023 1:05 AM, Christian König wrote:


Am 14.06.23 um 18:15 schrieb Jeffrey Hugo:
From: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@xxxxxxxxxxx>

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@xxxxxxxxx>
Closes: https://lore.kernel.org/all/20230610021200.377452-1-sukrut.bellary@xxxxxxxxx/
Suggested-by: Christian König <christian.koenig@xxxxxxx>
Signed-off-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@xxxxxxxxxxx>
Reviewed-by: Carl Vanderlip <quic_carlv@xxxxxxxxxxx>
Reviewed-by: Jeffrey Hugo <quic_jhugo@xxxxxxxxxxx>
Signed-off-by: Jeffrey Hugo <quic_jhugo@xxxxxxxxxxx>

Reviewed-by: Christian König <christian.koenig@xxxxxxx>

Thanks for the guidance and review!