mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Xiyu Yang <xiyuyang19@fudan.edu.cn>,
	Huang Rui <ray.huang@amd.com>, David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel@ffwll.ch>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org
Cc: yuanxzhang@fudan.edu.cn, kjlu@umn.edu, Xin Tan <tanxin.ctf@gmail.com>
Subject: Re: [PATCH] drm/ttm: Fix dma_fence refcnt leak in ttm_bo_vm_fault_reserved
Date: Sat, 13 Jun 2020 17:08:58 +0200	[thread overview]
Message-ID: <5f1e83d6-9d3b-f7dc-d3e7-4f8ca46e9855@amd.com> (raw)
In-Reply-To: <1592051318-93958-1-git-send-email-xiyuyang19@fudan.edu.cn>

Am 13.06.20 um 14:28 schrieb Xiyu Yang:
> ttm_bo_vm_fault_reserved() invokes dma_fence_get(), which returns a
> reference of the specified dma_fence object to "moving" with increased
> refcnt.
>
> When ttm_bo_vm_fault_reserved() returns, local variable "moving" becomes
> invalid, so the refcount should be decreased to keep refcount balanced.
>
> The reference counting issue happens in several exception handling paths
> of ttm_bo_vm_fault_reserved(). When those error scenarios occur such as
> "err" equals to -EBUSY, the function forgets to decrease the refcnt
> increased by dma_fence_get(), causing a refcnt leak.
>
> Fix this issue by calling dma_fence_put() when no_wait_gpu flag is
> equals to true.
>
> Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>

Good catch, Reviewed-by: Christian König <christian.koenig@amd.com>.

Going to pick that up for drm-misc-fixes.

Christian.

> ---
>   drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index a43aa7275f12..fa03fab02076 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -300,8 +300,10 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
>   			break;
>   		case -EBUSY:
>   		case -ERESTARTSYS:
> +			dma_fence_put(moving);
>   			return VM_FAULT_NOPAGE;
>   		default:
> +			dma_fence_put(moving);
>   			return VM_FAULT_SIGBUS;
>   		}
>   


      reply	other threads:[~2020-06-13 15:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-13 12:28 Xiyu Yang
2020-06-13 15:08 ` Christian König [this message]

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=5f1e83d6-9d3b-f7dc-d3e7-4f8ca46e9855@amd.com \
    --to=christian.koenig@amd.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kjlu@umn.edu \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=ray.huang@amd.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tanxin.ctf@gmail.com \
    --cc=xiyuyang19@fudan.edu.cn \
    --cc=yuanxzhang@fudan.edu.cn \
    /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

all inboxes | Powered by JetHome®