dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Jeffrey Hugo <quic_jhugo@quicinc.com>,
	quic_carlv@quicinc.com, quic_pkanojiy@quicinc.com,
	sukrut.bellary@linux.com, sumit.semwal@linaro.org
Cc: linux-arm-msm@vger.kernel.org, ogabbay@kernel.org,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
	linux-media@vger.kernel.org
Subject: Re: [PATCH] accel/qaic: Call DRM helper function to destroy prime GEM
Date: Thu, 15 Jun 2023 09:05:12 +0200	[thread overview]
Message-ID: <87ce15c9-670e-f270-94b7-580b0a54f59f@amd.com> (raw)
In-Reply-To: <20230614161528.11710-1-quic_jhugo@quicinc.com>



Am 14.06.23 um 18:15 schrieb Jeffrey Hugo:
> From: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
>
> 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>

> ---
>   drivers/accel/qaic/qaic_data.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
> index e42c1f9ffff8..e9a1cb779b30 100644
> --- a/drivers/accel/qaic/qaic_data.c
> +++ b/drivers/accel/qaic/qaic_data.c
> @@ -23,6 +23,7 @@
>   #include <linux/wait.h>
>   #include <drm/drm_file.h>
>   #include <drm/drm_gem.h>
> +#include <drm/drm_prime.h>
>   #include <drm/drm_print.h>
>   #include <uapi/drm/qaic_accel.h>
>   
> @@ -616,8 +617,7 @@ static void qaic_free_object(struct drm_gem_object *obj)
>   
>   	if (obj->import_attach) {
>   		/* DMABUF/PRIME Path */
> -		dma_buf_detach(obj->import_attach->dmabuf, obj->import_attach);
> -		dma_buf_put(obj->import_attach->dmabuf);
> +		drm_prime_gem_destroy(obj, NULL);
>   	} else {
>   		/* Private buffer allocation path */
>   		qaic_free_sgt(bo->sgt);


  reply	other threads:[~2023-06-15  7:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14 16:15 [PATCH] accel/qaic: Call DRM helper function to destroy prime GEM Jeffrey Hugo
2023-06-15  7:05 ` Christian König [this message]
2023-06-15 15:23   ` Jeffrey Hugo
2023-06-20 14:17 ` Jeffrey Hugo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ce15c9-670e-f270-94b7-580b0a54f59f@amd.com \
    --to=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=ogabbay@kernel.org \
    --cc=quic_carlv@quicinc.com \
    --cc=quic_jhugo@quicinc.com \
    --cc=quic_pkanojiy@quicinc.com \
    --cc=sukrut.bellary@linux.com \
    --cc=sumit.semwal@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).