AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/syncobj: fix leaking dma_fence in drm_syncobj_query_ioctl
@ 2019-07-22 12:59 Christian König
  2019-07-22 13:16 ` Lionel Landwerlin
  0 siblings, 1 reply; 4+ messages in thread
From: Christian König @ 2019-07-22 12:59 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

We need to check the context number instead if the previous sequence to detect
an error and if an error is detected we need to drop the reference to the
current fence or otherwise would leak it.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/drm_syncobj.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 75cb4bb7619e..1438dcb3ebb1 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -1298,14 +1298,14 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
 			struct dma_fence *iter, *last_signaled = NULL;
 
 			dma_fence_chain_for_each(iter, fence) {
-				if (!iter)
-					break;
-				dma_fence_put(last_signaled);
-				last_signaled = dma_fence_get(iter);
-				if (!to_dma_fence_chain(last_signaled)->prev_seqno)
+				if (iter->context != fence->context) {
+					dma_fence_put(iter);
 					/* It is most likely that timeline has
 					 * unorder points. */
 					break;
+				}
+				dma_fence_put(last_signaled);
+				last_signaled = dma_fence_get(iter);
 			}
 			point = dma_fence_is_signaled(last_signaled) ?
 				last_signaled->seqno :
-- 
2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/syncobj: fix leaking dma_fence in drm_syncobj_query_ioctl
  2019-07-22 12:59 [PATCH] drm/syncobj: fix leaking dma_fence in drm_syncobj_query_ioctl Christian König
@ 2019-07-22 13:16 ` Lionel Landwerlin
  2019-07-22 13:21   ` Christian König
  0 siblings, 1 reply; 4+ messages in thread
From: Lionel Landwerlin @ 2019-07-22 13:16 UTC (permalink / raw)
  To: Christian König, amd-gfx, dri-devel

On 22/07/2019 15:59, Christian König wrote:
> We need to check the context number instead if the previous sequence to detect
> an error and if an error is detected we need to drop the reference to the
> current fence or otherwise would leak it.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>

Fixes: 27b575a9aa2f ("drm/syncobj: add timeline payload query ioctl v6")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>

> ---
>   drivers/gpu/drm/drm_syncobj.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index 75cb4bb7619e..1438dcb3ebb1 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -1298,14 +1298,14 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
>   			struct dma_fence *iter, *last_signaled = NULL;
>   
>   			dma_fence_chain_for_each(iter, fence) {
> -				if (!iter)
> -					break;
> -				dma_fence_put(last_signaled);
> -				last_signaled = dma_fence_get(iter);
> -				if (!to_dma_fence_chain(last_signaled)->prev_seqno)
> +				if (iter->context != fence->context) {
> +					dma_fence_put(iter);
>   					/* It is most likely that timeline has
>   					 * unorder points. */
>   					break;
> +				}
> +				dma_fence_put(last_signaled);
> +				last_signaled = dma_fence_get(iter);
>   			}
>   			point = dma_fence_is_signaled(last_signaled) ?
>   				last_signaled->seqno :


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/syncobj: fix leaking dma_fence in drm_syncobj_query_ioctl
  2019-07-22 13:16 ` Lionel Landwerlin
@ 2019-07-22 13:21   ` Christian König
       [not found]     ` <a4c1c291-bff1-d7cb-f510-fdea63e1eb9b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Christian König @ 2019-07-22 13:21 UTC (permalink / raw)
  To: Lionel Landwerlin, amd-gfx, dri-devel

Am 22.07.19 um 15:16 schrieb Lionel Landwerlin:
> On 22/07/2019 15:59, Christian König wrote:
>> We need to check the context number instead if the previous sequence 
>> to detect
>> an error and if an error is detected we need to drop the reference to 
>> the
>> current fence or otherwise would leak it.
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>
> Fixes: 27b575a9aa2f ("drm/syncobj: add timeline payload query ioctl v6")
> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>

CC stable? I'm not sure when this got upstream.

Christian.

>
>> ---
>>   drivers/gpu/drm/drm_syncobj.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_syncobj.c 
>> b/drivers/gpu/drm/drm_syncobj.c
>> index 75cb4bb7619e..1438dcb3ebb1 100644
>> --- a/drivers/gpu/drm/drm_syncobj.c
>> +++ b/drivers/gpu/drm/drm_syncobj.c
>> @@ -1298,14 +1298,14 @@ int drm_syncobj_query_ioctl(struct drm_device 
>> *dev, void *data,
>>               struct dma_fence *iter, *last_signaled = NULL;
>>                 dma_fence_chain_for_each(iter, fence) {
>> -                if (!iter)
>> -                    break;
>> -                dma_fence_put(last_signaled);
>> -                last_signaled = dma_fence_get(iter);
>> -                if (!to_dma_fence_chain(last_signaled)->prev_seqno)
>> +                if (iter->context != fence->context) {
>> +                    dma_fence_put(iter);
>>                       /* It is most likely that timeline has
>>                        * unorder points. */
>>                       break;
>> +                }
>> +                dma_fence_put(last_signaled);
>> +                last_signaled = dma_fence_get(iter);
>>               }
>>               point = dma_fence_is_signaled(last_signaled) ?
>>                   last_signaled->seqno :
>
>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/syncobj: fix leaking dma_fence in drm_syncobj_query_ioctl
       [not found]     ` <a4c1c291-bff1-d7cb-f510-fdea63e1eb9b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2019-07-22 13:35       ` Lionel Landwerlin
  0 siblings, 0 replies; 4+ messages in thread
From: Lionel Landwerlin @ 2019-07-22 13:35 UTC (permalink / raw)
  To: christian.koenig-5C7GfCeVMHo,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 22/07/2019 16:21, Christian König wrote:
> Am 22.07.19 um 15:16 schrieb Lionel Landwerlin:
>> On 22/07/2019 15:59, Christian König wrote:
>>> We need to check the context number instead if the previous sequence 
>>> to detect
>>> an error and if an error is detected we need to drop the reference 
>>> to the
>>> current fence or otherwise would leak it.
>>>
>>> Signed-off-by: Christian König <christian.koenig@amd.com>
>>
>> Fixes: 27b575a9aa2f ("drm/syncobj: add timeline payload query ioctl v6")
>> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
>
> CC stable? I'm not sure when this got upstream.
>
> Christian.


I thought it would get picked up automatically for the relevant stable 
version (and none if it's not upstream yet).

We also have to be nice to people cherry picking stuff like ChromeOS.


-Lionel


>
>>
>>> ---
>>>   drivers/gpu/drm/drm_syncobj.c | 10 +++++-----
>>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_syncobj.c 
>>> b/drivers/gpu/drm/drm_syncobj.c
>>> index 75cb4bb7619e..1438dcb3ebb1 100644
>>> --- a/drivers/gpu/drm/drm_syncobj.c
>>> +++ b/drivers/gpu/drm/drm_syncobj.c
>>> @@ -1298,14 +1298,14 @@ int drm_syncobj_query_ioctl(struct 
>>> drm_device *dev, void *data,
>>>               struct dma_fence *iter, *last_signaled = NULL;
>>>                 dma_fence_chain_for_each(iter, fence) {
>>> -                if (!iter)
>>> -                    break;
>>> -                dma_fence_put(last_signaled);
>>> -                last_signaled = dma_fence_get(iter);
>>> -                if (!to_dma_fence_chain(last_signaled)->prev_seqno)
>>> +                if (iter->context != fence->context) {
>>> +                    dma_fence_put(iter);
>>>                       /* It is most likely that timeline has
>>>                        * unorder points. */
>>>                       break;
>>> +                }
>>> +                dma_fence_put(last_signaled);
>>> +                last_signaled = dma_fence_get(iter);
>>>               }
>>>               point = dma_fence_is_signaled(last_signaled) ?
>>>                   last_signaled->seqno :
>>
>>
>
>

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-22 13:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-22 12:59 [PATCH] drm/syncobj: fix leaking dma_fence in drm_syncobj_query_ioctl Christian König
2019-07-22 13:16 ` Lionel Landwerlin
2019-07-22 13:21   ` Christian König
     [not found]     ` <a4c1c291-bff1-d7cb-f510-fdea63e1eb9b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-07-22 13:35       ` Lionel Landwerlin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox