All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: "Christian König" <christian.koenig@amd.com>
Cc: Xin Xiong <xiongx18@fudan.edu.cn>,
	Alex Deucher <alexander.deucher@amd.com>,
	"Pan, Xinhui" <Xinhui.Pan@amd.com>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	amd-gfx list <amd-gfx@lists.freedesktop.org>,
	Maling list - DRI developers  <dri-devel@lists.freedesktop.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-media <linux-media@vger.kernel.org>,
	"moderated list:DMA BUFFER SHARING FRAMEWORK" 
	<linaro-mm-sig@lists.linaro.org>, Xin Tan <tanxin.ctf@gmail.com>,
	yuanxzhang@fudan.edu.cn
Subject: Re: [PATCH] drm/amd/amdgpu/amdgpu_cs: fix refcount leak of a dma_fence obj
Date: Fri, 21 Jan 2022 15:48:13 -0500	[thread overview]
Message-ID: <CADnq5_N5Di8mxWDoVe5hdqPfrBnCw=gnDMzMyHeenk2gb=aSZw@mail.gmail.com> (raw)
In-Reply-To: <23d5251f-c910-aed3-5d9e-07d6e5e5add2@amd.com>

On Fri, Jan 21, 2022 at 2:45 AM Christian König
<christian.koenig@amd.com> wrote:
>
> Am 21.01.22 um 06:28 schrieb Xin Xiong:
> > This issue takes place in an error path in
> > amdgpu_cs_fence_to_handle_ioctl(). When `info->in.what` falls into
> > default case, the function simply returns -EINVAL, forgetting to
> > decrement the reference count of a dma_fence obj, which is bumped
> > earlier by amdgpu_cs_get_fence(). This may result in reference count
> > leaks.
> >
> > Fix it by decreasing the refcount of specific object before returning
> > the error code.
> >
> > Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
> > Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
>
> Good catch. Reviewed-by: Christian König <christian.koenig@amd.com>

Applied manually.  Strangely I never got this on any of my emails, and
I don't see it in the archives.

Alex

>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > index 0311d799a..894869789 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > @@ -1510,6 +1510,7 @@ int amdgpu_cs_fence_to_handle_ioctl(struct drm_device *dev, void *data,
> >               return 0;
> >
> >       default:
> > +             dma_fence_put(fence);
> >               return -EINVAL;
> >       }
> >   }
>

WARNING: multiple messages have this Message-ID (diff)
From: Alex Deucher <alexdeucher@gmail.com>
To: "Christian König" <christian.koenig@amd.com>
Cc: Xin Tan <tanxin.ctf@gmail.com>,
	yuanxzhang@fudan.edu.cn, David Airlie <airlied@linux.ie>,
	Maling list - DRI developers <dri-devel@lists.freedesktop.org>,
	"Pan, Xinhui" <Xinhui.Pan@amd.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Xin Xiong <xiongx18@fudan.edu.cn>,
	"moderated list:DMA BUFFER SHARING FRAMEWORK"
	<linaro-mm-sig@lists.linaro.org>,
	amd-gfx list <amd-gfx@lists.freedesktop.org>,
	Alex Deucher <alexander.deucher@amd.com>,
	linux-media <linux-media@vger.kernel.org>
Subject: Re: [PATCH] drm/amd/amdgpu/amdgpu_cs: fix refcount leak of a dma_fence obj
Date: Fri, 21 Jan 2022 15:48:13 -0500	[thread overview]
Message-ID: <CADnq5_N5Di8mxWDoVe5hdqPfrBnCw=gnDMzMyHeenk2gb=aSZw@mail.gmail.com> (raw)
In-Reply-To: <23d5251f-c910-aed3-5d9e-07d6e5e5add2@amd.com>

On Fri, Jan 21, 2022 at 2:45 AM Christian König
<christian.koenig@amd.com> wrote:
>
> Am 21.01.22 um 06:28 schrieb Xin Xiong:
> > This issue takes place in an error path in
> > amdgpu_cs_fence_to_handle_ioctl(). When `info->in.what` falls into
> > default case, the function simply returns -EINVAL, forgetting to
> > decrement the reference count of a dma_fence obj, which is bumped
> > earlier by amdgpu_cs_get_fence(). This may result in reference count
> > leaks.
> >
> > Fix it by decreasing the refcount of specific object before returning
> > the error code.
> >
> > Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
> > Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
>
> Good catch. Reviewed-by: Christian König <christian.koenig@amd.com>

Applied manually.  Strangely I never got this on any of my emails, and
I don't see it in the archives.

Alex

>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > index 0311d799a..894869789 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > @@ -1510,6 +1510,7 @@ int amdgpu_cs_fence_to_handle_ioctl(struct drm_device *dev, void *data,
> >               return 0;
> >
> >       default:
> > +             dma_fence_put(fence);
> >               return -EINVAL;
> >       }
> >   }
>

WARNING: multiple messages have this Message-ID (diff)
From: Alex Deucher <alexdeucher@gmail.com>
To: "Christian König" <christian.koenig@amd.com>
Cc: Xin Tan <tanxin.ctf@gmail.com>,
	yuanxzhang@fudan.edu.cn, David Airlie <airlied@linux.ie>,
	Maling list - DRI developers <dri-devel@lists.freedesktop.org>,
	"Pan, Xinhui" <Xinhui.Pan@amd.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Xin Xiong <xiongx18@fudan.edu.cn>,
	"moderated list:DMA BUFFER SHARING FRAMEWORK"
	<linaro-mm-sig@lists.linaro.org>,
	amd-gfx list <amd-gfx@lists.freedesktop.org>,
	Daniel Vetter <daniel@ffwll.ch>,
	Alex Deucher <alexander.deucher@amd.com>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	linux-media <linux-media@vger.kernel.org>
Subject: Re: [PATCH] drm/amd/amdgpu/amdgpu_cs: fix refcount leak of a dma_fence obj
Date: Fri, 21 Jan 2022 15:48:13 -0500	[thread overview]
Message-ID: <CADnq5_N5Di8mxWDoVe5hdqPfrBnCw=gnDMzMyHeenk2gb=aSZw@mail.gmail.com> (raw)
In-Reply-To: <23d5251f-c910-aed3-5d9e-07d6e5e5add2@amd.com>

On Fri, Jan 21, 2022 at 2:45 AM Christian König
<christian.koenig@amd.com> wrote:
>
> Am 21.01.22 um 06:28 schrieb Xin Xiong:
> > This issue takes place in an error path in
> > amdgpu_cs_fence_to_handle_ioctl(). When `info->in.what` falls into
> > default case, the function simply returns -EINVAL, forgetting to
> > decrement the reference count of a dma_fence obj, which is bumped
> > earlier by amdgpu_cs_get_fence(). This may result in reference count
> > leaks.
> >
> > Fix it by decreasing the refcount of specific object before returning
> > the error code.
> >
> > Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
> > Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
>
> Good catch. Reviewed-by: Christian König <christian.koenig@amd.com>

Applied manually.  Strangely I never got this on any of my emails, and
I don't see it in the archives.

Alex

>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > index 0311d799a..894869789 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> > @@ -1510,6 +1510,7 @@ int amdgpu_cs_fence_to_handle_ioctl(struct drm_device *dev, void *data,
> >               return 0;
> >
> >       default:
> > +             dma_fence_put(fence);
> >               return -EINVAL;
> >       }
> >   }
>

  reply	other threads:[~2022-01-21 20:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-21  5:28 [PATCH] drm/amd/amdgpu/amdgpu_cs: fix refcount leak of a dma_fence obj Xin Xiong
2022-01-21  7:45 ` Christian König
2022-01-21  7:45   ` Christian König
2022-01-21 20:48   ` Alex Deucher [this message]
2022-01-21 20:48     ` Alex Deucher
2022-01-21 20:48     ` Alex Deucher

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='CADnq5_N5Di8mxWDoVe5hdqPfrBnCw=gnDMzMyHeenk2gb=aSZw@mail.gmail.com' \
    --to=alexdeucher@gmail.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=sumit.semwal@linaro.org \
    --cc=tanxin.ctf@gmail.com \
    --cc=xiongx18@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.