* [PATCH] drm/amdgpu: fix memory leak
@ 2019-10-04 10:17 Nirmoy Das
2019-10-04 10:44 ` Koenig, Christian
0 siblings, 1 reply; 17+ messages in thread
From: Nirmoy Das @ 2019-10-04 10:17 UTC (permalink / raw)
To: alexander.deucher, christian.koenig
Cc: airlied, dri-devel, linux-kernel, nirmoy.das
In amdgpu_bo_list_ioctl when idr_alloc fails
don't return without freeing bo list entry.
Fixes: 964d0fbf6301d ("drm/amdgpu: Allow to create BO lists in CS ioctl v3")
Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
index 7bcf86c61999..c3e5ea544857 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
@@ -284,7 +284,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
mutex_unlock(&fpriv->bo_list_lock);
if (r < 0) {
amdgpu_bo_list_put(list);
- return r;
+ goto error_free;
}
handle = r;
--
2.23.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/amdgpu: fix memory leak
2019-10-04 10:17 [PATCH] drm/amdgpu: fix memory leak Nirmoy Das
@ 2019-10-04 10:44 ` Koenig, Christian
0 siblings, 0 replies; 17+ messages in thread
From: Koenig, Christian @ 2019-10-04 10:44 UTC (permalink / raw)
To: Nirmoy Das, Deucher, Alexander
Cc: airlied, dri-devel, linux-kernel, Das, Nirmoy
First of all please send mails regarding amdgpu to the amd-gfx mailing
list and not lkml/dri-devel.
Am 04.10.19 um 12:17 schrieb Nirmoy Das:
> In amdgpu_bo_list_ioctl when idr_alloc fails
> don't return without freeing bo list entry.
>
> Fixes: 964d0fbf6301d ("drm/amdgpu: Allow to create BO lists in CS ioctl v3")
>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> index 7bcf86c61999..c3e5ea544857 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> @@ -284,7 +284,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
> mutex_unlock(&fpriv->bo_list_lock);
> if (r < 0) {
> amdgpu_bo_list_put(list);
> - return r;
> + goto error_free;
NAK, that is a double free. The bo list entries are freed by
amdgpu_bo_list_put().
Regards,
Christian.
> }
>
> handle = r;
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/amdgpu: fix memory leak
@ 2019-10-04 10:44 ` Koenig, Christian
0 siblings, 0 replies; 17+ messages in thread
From: Koenig, Christian @ 2019-10-04 10:44 UTC (permalink / raw)
To: Nirmoy Das, Deucher, Alexander
Cc: airlied, Das, Nirmoy, linux-kernel, dri-devel
First of all please send mails regarding amdgpu to the amd-gfx mailing
list and not lkml/dri-devel.
Am 04.10.19 um 12:17 schrieb Nirmoy Das:
> In amdgpu_bo_list_ioctl when idr_alloc fails
> don't return without freeing bo list entry.
>
> Fixes: 964d0fbf6301d ("drm/amdgpu: Allow to create BO lists in CS ioctl v3")
>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> index 7bcf86c61999..c3e5ea544857 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> @@ -284,7 +284,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
> mutex_unlock(&fpriv->bo_list_lock);
> if (r < 0) {
> amdgpu_bo_list_put(list);
> - return r;
> + goto error_free;
NAK, that is a double free. The bo list entries are freed by
amdgpu_bo_list_put().
Regards,
Christian.
> }
>
> handle = r;
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/amdgpu: fix memory leak
2019-10-04 10:44 ` Koenig, Christian
(?)
@ 2019-10-04 11:00 ` Nirmoy
2019-10-04 11:13 ` Koenig, Christian
-1 siblings, 1 reply; 17+ messages in thread
From: Nirmoy @ 2019-10-04 11:00 UTC (permalink / raw)
To: Koenig, Christian, Nirmoy Das, Deucher, Alexander
Cc: airlied, dri-devel, linux-kernel, Das, Nirmoy
On 10/4/19 12:44 PM, Koenig, Christian wrote:
> First of all please send mails regarding amdgpu to the amd-gfx mailing
> list and not lkml/dri-devel.
Okay.
> Am 04.10.19 um 12:17 schrieb Nirmoy Das:
>> In amdgpu_bo_list_ioctl when idr_alloc fails
>> don't return without freeing bo list entry.
>>
>> Fixes: 964d0fbf6301d ("drm/amdgpu: Allow to create BO lists in CS ioctl v3")
>>
>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
>> index 7bcf86c61999..c3e5ea544857 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
>> @@ -284,7 +284,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
>> mutex_unlock(&fpriv->bo_list_lock);
>> if (r < 0) {
>> amdgpu_bo_list_put(list);
>> - return r;
>> + goto error_free;
> NAK, that is a double free. The bo list entries are freed by
> amdgpu_bo_list_put().
Thanks, didn't realize that.
> Regards,
> Christian.
Regards,
Nirmoy
>> }
>>
>> handle = r;
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/amdgpu: fix memory leak
2019-10-04 11:00 ` Nirmoy
@ 2019-10-04 11:13 ` Koenig, Christian
0 siblings, 0 replies; 17+ messages in thread
From: Koenig, Christian @ 2019-10-04 11:13 UTC (permalink / raw)
To: Das, Nirmoy, Nirmoy Das, Deucher, Alexander
Cc: airlied, dri-devel, linux-kernel
Am 04.10.19 um 13:00 schrieb Das, Nirmoy:
> On 10/4/19 12:44 PM, Koenig, Christian wrote:
>> First of all please send mails regarding amdgpu to the amd-gfx mailing
>> list and not lkml/dri-devel.
> Okay.
>> Am 04.10.19 um 12:17 schrieb Nirmoy Das:
>>> In amdgpu_bo_list_ioctl when idr_alloc fails
>>> don't return without freeing bo list entry.
>>>
>>> Fixes: 964d0fbf6301d ("drm/amdgpu: Allow to create BO lists in CS ioctl v3")
>>>
>>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>>> ---
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
>>> index 7bcf86c61999..c3e5ea544857 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
>>> @@ -284,7 +284,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
>>> mutex_unlock(&fpriv->bo_list_lock);
>>> if (r < 0) {
>>> amdgpu_bo_list_put(list);
>>> - return r;
>>> + goto error_free;
>> NAK, that is a double free. The bo list entries are freed by
>> amdgpu_bo_list_put().
> Thanks, didn't realize that.
Wait a second, what entries are you talking about?
The entries in the list object are freed when amdgpu_bo_list_put() is
called, but the temporary info array with the handles needs to be freed
as well.
And it looks like that is indeed leaked here.
Regards,
Christian.
>> Regards,
>> Christian.
> Regards,
>
> Nirmoy
>
>>> }
>>>
>>> handle = r;
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/amdgpu: fix memory leak
@ 2019-10-04 11:13 ` Koenig, Christian
0 siblings, 0 replies; 17+ messages in thread
From: Koenig, Christian @ 2019-10-04 11:13 UTC (permalink / raw)
To: Das, Nirmoy, Nirmoy Das, Deucher, Alexander
Cc: airlied, linux-kernel, dri-devel
Am 04.10.19 um 13:00 schrieb Das, Nirmoy:
> On 10/4/19 12:44 PM, Koenig, Christian wrote:
>> First of all please send mails regarding amdgpu to the amd-gfx mailing
>> list and not lkml/dri-devel.
> Okay.
>> Am 04.10.19 um 12:17 schrieb Nirmoy Das:
>>> In amdgpu_bo_list_ioctl when idr_alloc fails
>>> don't return without freeing bo list entry.
>>>
>>> Fixes: 964d0fbf6301d ("drm/amdgpu: Allow to create BO lists in CS ioctl v3")
>>>
>>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>>> ---
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
>>> index 7bcf86c61999..c3e5ea544857 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
>>> @@ -284,7 +284,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
>>> mutex_unlock(&fpriv->bo_list_lock);
>>> if (r < 0) {
>>> amdgpu_bo_list_put(list);
>>> - return r;
>>> + goto error_free;
>> NAK, that is a double free. The bo list entries are freed by
>> amdgpu_bo_list_put().
> Thanks, didn't realize that.
Wait a second, what entries are you talking about?
The entries in the list object are freed when amdgpu_bo_list_put() is
called, but the temporary info array with the handles needs to be freed
as well.
And it looks like that is indeed leaked here.
Regards,
Christian.
>> Regards,
>> Christian.
> Regards,
>
> Nirmoy
>
>>> }
>>>
>>> handle = r;
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/amdgpu: fix memory leak
2019-10-04 11:13 ` Koenig, Christian
@ 2019-10-04 11:26 ` Nirmoy
-1 siblings, 0 replies; 17+ messages in thread
From: Nirmoy @ 2019-10-04 11:26 UTC (permalink / raw)
To: Koenig, Christian, Das, Nirmoy, Nirmoy Das, Deucher, Alexander
Cc: airlied, dri-devel, linux-kernel
On 10/4/19 1:13 PM, Koenig, Christian wrote:
>
>>> NAK, that is a double free. The bo list entries are freed by
>>> amdgpu_bo_list_put().
>> Thanks, didn't realize that.
> Wait a second, what entries are you talking about?
>
> The entries in the list object are freed when amdgpu_bo_list_put() is
> called, but the temporary info array with the handles needs to be freed
> as well.
>
> And it looks like that is indeed leaked here.
I am talking about the `info` array created by
amdgpu_bo_create_list_entry_array().
> Regards,
> Christian.
>
>>> Regards,
>>> Christian.
>> Regards,
>>
>> Nirmoy
>>
>>>> }
>>>>
>>>> handle = r;
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/amdgpu: fix memory leak
@ 2019-10-04 11:26 ` Nirmoy
0 siblings, 0 replies; 17+ messages in thread
From: Nirmoy @ 2019-10-04 11:26 UTC (permalink / raw)
To: Koenig, Christian, Das, Nirmoy, Nirmoy Das, Deucher, Alexander
Cc: airlied, linux-kernel, dri-devel
On 10/4/19 1:13 PM, Koenig, Christian wrote:
>
>>> NAK, that is a double free. The bo list entries are freed by
>>> amdgpu_bo_list_put().
>> Thanks, didn't realize that.
> Wait a second, what entries are you talking about?
>
> The entries in the list object are freed when amdgpu_bo_list_put() is
> called, but the temporary info array with the handles needs to be freed
> as well.
>
> And it looks like that is indeed leaked here.
I am talking about the `info` array created by
amdgpu_bo_create_list_entry_array().
> Regards,
> Christian.
>
>>> Regards,
>>> Christian.
>> Regards,
>>
>> Nirmoy
>>
>>>> }
>>>>
>>>> handle = r;
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/amdgpu: fix memory leak
2019-10-04 11:26 ` Nirmoy
(?)
@ 2019-10-04 11:30 ` Koenig, Christian
2019-10-04 11:36 ` Nirmoy
-1 siblings, 1 reply; 17+ messages in thread
From: Koenig, Christian @ 2019-10-04 11:30 UTC (permalink / raw)
To: Das, Nirmoy, Nirmoy Das, Deucher, Alexander
Cc: airlied, dri-devel, linux-kernel
Am 04.10.19 um 13:26 schrieb Das, Nirmoy:
> On 10/4/19 1:13 PM, Koenig, Christian wrote:
>>>> NAK, that is a double free. The bo list entries are freed by
>>>> amdgpu_bo_list_put().
>>> Thanks, didn't realize that.
>> Wait a second, what entries are you talking about?
>>
>> The entries in the list object are freed when amdgpu_bo_list_put() is
>> called, but the temporary info array with the handles needs to be freed
>> as well.
>>
>> And it looks like that is indeed leaked here.
> I am talking about the `info` array created by
> amdgpu_bo_create_list_entry_array().
Yeah, that are the handles and not the entries. Sorry that I was
confused about that.
Your patch is correct, you should just update the commit message a bit.
BTW: Could you cleanup error handling here a bit more?
E.g. add an error_put_list handle and drop the "if (info)" and instead
return directly if we fail to allocate info.
Thanks,
Christian.
>> Regards,
>> Christian.
>>
>>>> Regards,
>>>> Christian.
>>> Regards,
>>>
>>> Nirmoy
>>>
>>>>> }
>>>>>
>>>>> handle = r;
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/amdgpu: fix memory leak
2019-10-04 11:30 ` Koenig, Christian
@ 2019-10-04 11:36 ` Nirmoy
0 siblings, 0 replies; 17+ messages in thread
From: Nirmoy @ 2019-10-04 11:36 UTC (permalink / raw)
To: Koenig, Christian, Das, Nirmoy, Nirmoy Das, Deucher, Alexander
Cc: airlied, dri-devel, linux-kernel
On 10/4/19 1:30 PM, Koenig, Christian wrote:
> Am 04.10.19 um 13:26 schrieb Das, Nirmoy:
>> On 10/4/19 1:13 PM, Koenig, Christian wrote:
>>>>> NAK, that is a double free. The bo list entries are freed by
>>>>> amdgpu_bo_list_put().
>>>> Thanks, didn't realize that.
>>> Wait a second, what entries are you talking about?
>>>
>>> The entries in the list object are freed when amdgpu_bo_list_put() is
>>> called, but the temporary info array with the handles needs to be freed
>>> as well.
>>>
>>> And it looks like that is indeed leaked here.
>> I am talking about the `info` array created by
>> amdgpu_bo_create_list_entry_array().
> Yeah, that are the handles and not the entries. Sorry that I was
> confused about that.
>
> Your patch is correct, you should just update the commit message a bit.
>
> BTW: Could you cleanup error handling here a bit more?
>
> E.g. add an error_put_list handle and drop the "if (info)" and instead
> return directly if we fail to allocate info.
Okay I will do that in v2 of this patch.
> Thanks,
> Christian.
Regards,
Nirmoy
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/amdgpu: fix memory leak
@ 2019-10-04 11:36 ` Nirmoy
0 siblings, 0 replies; 17+ messages in thread
From: Nirmoy @ 2019-10-04 11:36 UTC (permalink / raw)
To: Koenig, Christian, Das, Nirmoy, Nirmoy Das, Deucher, Alexander
Cc: airlied, linux-kernel, dri-devel
On 10/4/19 1:30 PM, Koenig, Christian wrote:
> Am 04.10.19 um 13:26 schrieb Das, Nirmoy:
>> On 10/4/19 1:13 PM, Koenig, Christian wrote:
>>>>> NAK, that is a double free. The bo list entries are freed by
>>>>> amdgpu_bo_list_put().
>>>> Thanks, didn't realize that.
>>> Wait a second, what entries are you talking about?
>>>
>>> The entries in the list object are freed when amdgpu_bo_list_put() is
>>> called, but the temporary info array with the handles needs to be freed
>>> as well.
>>>
>>> And it looks like that is indeed leaked here.
>> I am talking about the `info` array created by
>> amdgpu_bo_create_list_entry_array().
> Yeah, that are the handles and not the entries. Sorry that I was
> confused about that.
>
> Your patch is correct, you should just update the commit message a bit.
>
> BTW: Could you cleanup error handling here a bit more?
>
> E.g. add an error_put_list handle and drop the "if (info)" and instead
> return directly if we fail to allocate info.
Okay I will do that in v2 of this patch.
> Thanks,
> Christian.
Regards,
Nirmoy
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/amdgpu: Fix memory leak
2021-03-17 9:55 [PATCH] drm/amdgpu: Fix " xinhui pan
@ 2021-03-17 13:44 ` Alex Deucher
0 siblings, 0 replies; 17+ messages in thread
From: Alex Deucher @ 2021-03-17 13:44 UTC (permalink / raw)
To: xinhui pan; +Cc: Deucher, Alexander, Kazlauskas, Nicholas, amd-gfx list
On Wed, Mar 17, 2021 at 5:56 AM xinhui pan <xinhui.pan@amd.com> wrote:
>
> drm_gem_object_put() should be paired with drm_gem_object_lookup().
>
> All gem objs are saved in fb->base.obj[]. Need put the old first before
> assign a new obj.
>
> Trigger VRAM leak by running command below
> $ service gdm restart
>
> Signed-off-by: xinhui pan <xinhui.pan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index bebed0f307a1..46dafea8da8b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -955,8 +955,9 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
> }
>
> for (i = 1; i < rfb->base.format->num_planes; ++i) {
> + drm_gem_object_get(rfb->base.obj[0]);
> + drm_gem_object_put(rfb->base.obj[i]);
> rfb->base.obj[i] = rfb->base.obj[0];
> - drm_gem_object_get(rfb->base.obj[i]);
> }
>
> return 0;
> @@ -1002,6 +1003,7 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
> return ERR_PTR(ret);
> }
>
> + drm_gem_object_put(obj);
> return &amdgpu_fb->base;
> }
>
> --
> 2.25.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH] drm/amdgpu: Fix memory leak
@ 2021-03-17 9:55 xinhui pan
2021-03-17 13:44 ` Alex Deucher
0 siblings, 1 reply; 17+ messages in thread
From: xinhui pan @ 2021-03-17 9:55 UTC (permalink / raw)
To: amd-gfx; +Cc: alexander.deucher, xinhui pan, nicholas.kazlauskas
drm_gem_object_put() should be paired with drm_gem_object_lookup().
All gem objs are saved in fb->base.obj[]. Need put the old first before
assign a new obj.
Trigger VRAM leak by running command below
$ service gdm restart
Signed-off-by: xinhui pan <xinhui.pan@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index bebed0f307a1..46dafea8da8b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -955,8 +955,9 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
}
for (i = 1; i < rfb->base.format->num_planes; ++i) {
+ drm_gem_object_get(rfb->base.obj[0]);
+ drm_gem_object_put(rfb->base.obj[i]);
rfb->base.obj[i] = rfb->base.obj[0];
- drm_gem_object_get(rfb->base.obj[i]);
}
return 0;
@@ -1002,6 +1003,7 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
return ERR_PTR(ret);
}
+ drm_gem_object_put(obj);
return &amdgpu_fb->base;
}
--
2.25.1
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/amdgpu: fix memory leak
[not found] ` <20191004135155.6527-1-nirmoy.das-5C7GfCeVMHo@public.gmane.org>
@ 2019-10-04 15:03 ` Koenig, Christian
0 siblings, 0 replies; 17+ messages in thread
From: Koenig, Christian @ 2019-10-04 15:03 UTC (permalink / raw)
To: Nirmoy Das, Deucher, Alexander
Cc: Das, Nirmoy, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Am 04.10.19 um 15:51 schrieb Nirmoy Das:
> cleanup error handling code and make sure temporary info array
> with the handles are freed by amdgpu_bo_list_put() on
> idr_replace()'s failure.
>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> index 7bcf86c61999..61e38e43ad1d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> @@ -270,7 +270,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
>
> r = amdgpu_bo_create_list_entry_array(&args->in, &info);
> if (r)
> - goto error_free;
> + return r;
>
> switch (args->in.operation) {
> case AMDGPU_BO_LIST_OP_CREATE:
> @@ -283,8 +283,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
> r = idr_alloc(&fpriv->bo_list_handles, list, 1, 0, GFP_KERNEL);
> mutex_unlock(&fpriv->bo_list_lock);
> if (r < 0) {
> - amdgpu_bo_list_put(list);
> - return r;
> + goto error_put_list;
> }
>
> handle = r;
> @@ -306,9 +305,8 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
> mutex_unlock(&fpriv->bo_list_lock);
>
> if (IS_ERR(old)) {
> - amdgpu_bo_list_put(list);
> r = PTR_ERR(old);
> - goto error_free;
> + goto error_put_list;
> }
>
> amdgpu_bo_list_put(old);
> @@ -325,8 +323,10 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
>
> return 0;
>
> +error_put_list:
> + amdgpu_bo_list_put(list);
> +
> error_free:
> - if (info)
> - kvfree(info);
> + kvfree(info);
> return r;
> }
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH] drm/amdgpu: fix memory leak
@ 2019-10-04 13:51 Nirmoy Das
[not found] ` <20191004135155.6527-1-nirmoy.das-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 17+ messages in thread
From: Nirmoy Das @ 2019-10-04 13:51 UTC (permalink / raw)
To: alexander.deucher-5C7GfCeVMHo, christian.koenig-5C7GfCeVMHo
Cc: nirmoy.das-5C7GfCeVMHo, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
cleanup error handling code and make sure temporary info array
with the handles are freed by amdgpu_bo_list_put() on
idr_replace()'s failure.
Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
index 7bcf86c61999..61e38e43ad1d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
@@ -270,7 +270,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
r = amdgpu_bo_create_list_entry_array(&args->in, &info);
if (r)
- goto error_free;
+ return r;
switch (args->in.operation) {
case AMDGPU_BO_LIST_OP_CREATE:
@@ -283,8 +283,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
r = idr_alloc(&fpriv->bo_list_handles, list, 1, 0, GFP_KERNEL);
mutex_unlock(&fpriv->bo_list_lock);
if (r < 0) {
- amdgpu_bo_list_put(list);
- return r;
+ goto error_put_list;
}
handle = r;
@@ -306,9 +305,8 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
mutex_unlock(&fpriv->bo_list_lock);
if (IS_ERR(old)) {
- amdgpu_bo_list_put(list);
r = PTR_ERR(old);
- goto error_free;
+ goto error_put_list;
}
amdgpu_bo_list_put(old);
@@ -325,8 +323,10 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
return 0;
+error_put_list:
+ amdgpu_bo_list_put(list);
+
error_free:
- if (info)
- kvfree(info);
+ kvfree(info);
return r;
}
--
2.23.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH] drm/amdgpu: fix memory leak
@ 2015-09-18 8:46 ` Sudip Mukherjee
0 siblings, 0 replies; 17+ messages in thread
From: Sudip Mukherjee @ 2015-09-18 8:46 UTC (permalink / raw)
To: David Airlie, Christian König
Cc: linux-kernel, dri-devel, Sudip Mukherjee
If amdgpu_ib_get() fails we returned the error code but we missed
freeing ib.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index f68b7cd..0e61074 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -455,8 +455,10 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
return -ENOMEM;
r = amdgpu_ib_get(ring, NULL, ndw * 4, ib);
- if (r)
+ if (r) {
+ kfree(ib);
return r;
+ }
ib->length_dw = 0;
/* walk over the address space and update the page directory */
--
1.9.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH] drm/amdgpu: fix memory leak
@ 2015-09-18 8:46 ` Sudip Mukherjee
0 siblings, 0 replies; 17+ messages in thread
From: Sudip Mukherjee @ 2015-09-18 8:46 UTC (permalink / raw)
To: David Airlie, Christian König
Cc: linux-kernel, dri-devel, Sudip Mukherjee
If amdgpu_ib_get() fails we returned the error code but we missed
freeing ib.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index f68b7cd..0e61074 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -455,8 +455,10 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
return -ENOMEM;
r = amdgpu_ib_get(ring, NULL, ndw * 4, ib);
- if (r)
+ if (r) {
+ kfree(ib);
return r;
+ }
ib->length_dw = 0;
/* walk over the address space and update the page directory */
--
1.9.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 17+ messages in thread
end of thread, other threads:[~2021-03-17 13:44 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 10:17 [PATCH] drm/amdgpu: fix memory leak Nirmoy Das
2019-10-04 10:44 ` Koenig, Christian
2019-10-04 10:44 ` Koenig, Christian
2019-10-04 11:00 ` Nirmoy
2019-10-04 11:13 ` Koenig, Christian
2019-10-04 11:13 ` Koenig, Christian
2019-10-04 11:26 ` Nirmoy
2019-10-04 11:26 ` Nirmoy
2019-10-04 11:30 ` Koenig, Christian
2019-10-04 11:36 ` Nirmoy
2019-10-04 11:36 ` Nirmoy
-- strict thread matches above, loose matches on Subject: below --
2021-03-17 9:55 [PATCH] drm/amdgpu: Fix " xinhui pan
2021-03-17 13:44 ` Alex Deucher
2019-10-04 13:51 [PATCH] drm/amdgpu: fix " Nirmoy Das
[not found] ` <20191004135155.6527-1-nirmoy.das-5C7GfCeVMHo@public.gmane.org>
2019-10-04 15:03 ` Koenig, Christian
2015-09-18 8:46 Sudip Mukherjee
2015-09-18 8:46 ` Sudip Mukherjee
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.