diff mbox

dma-buf/sync_file: free fences array in num_fences is 1

Message ID 1474442419-6040-1-git-send-email-gustavo@padovan.org (mailing list archive)
State New, archived
Headers show

Commit Message

Gustavo Padovan Sept. 21, 2016, 7:20 a.m. UTC
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

When merging sync_files there is a case when we can end up with only one
fence in the merged sync_file: when all fences belong to the same
timeline.

So for this case a fence_array is not created instead we just assigned the
fence to sync_file->fence. Then we do not use the fences array anymore nor
does free it.

This patch frees the array.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reported-by:  Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/dma-buf/sync_file.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Chris Wilson Sept. 21, 2016, 11:12 a.m. UTC | #1
On Wed, Sep 21, 2016 at 10:20:19AM +0300, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> 
> When merging sync_files there is a case when we can end up with only one
> fence in the merged sync_file: when all fences belong to the same
> timeline.
> 
> So for this case a fence_array is not created instead we just assigned the
> fence to sync_file->fence. Then we do not use the fences array anymore nor
> does free it.
> 
> This patch frees the array.
> 
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> Reported-by:  Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/dma-buf/sync_file.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
> index 706eea9..9ed4f9f 100644
> --- a/drivers/dma-buf/sync_file.c
> +++ b/drivers/dma-buf/sync_file.c
> @@ -150,6 +150,7 @@ static int sync_file_set_fence(struct sync_file *sync_file,
>  	 */
>  	if (num_fences == 1) {
>  		sync_file->fence = fences[0];
> +		kfree(fences);

Ok, that makes sense wrt the code. I don't see any particular advantage
in a warning comment, so
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
Sean Paul Sept. 22, 2016, 12:07 p.m. UTC | #2
On Wed, Sep 21, 2016 at 4:12 AM, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> On Wed, Sep 21, 2016 at 10:20:19AM +0300, Gustavo Padovan wrote:
>> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>>
>> When merging sync_files there is a case when we can end up with only one
>> fence in the merged sync_file: when all fences belong to the same
>> timeline.
>>
>> So for this case a fence_array is not created instead we just assigned the
>> fence to sync_file->fence. Then we do not use the fences array anymore nor
>> does free it.
>>
>> This patch frees the array.
>>
>> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>> Reported-by:  Chris Wilson <chris@chris-wilson.co.uk>
>> ---
>>  drivers/dma-buf/sync_file.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
>> index 706eea9..9ed4f9f 100644
>> --- a/drivers/dma-buf/sync_file.c
>> +++ b/drivers/dma-buf/sync_file.c
>> @@ -150,6 +150,7 @@ static int sync_file_set_fence(struct sync_file *sync_file,
>>        */
>>       if (num_fences == 1) {
>>               sync_file->fence = fences[0];
>> +             kfree(fences);
>
> Ok, that makes sense wrt the code. I don't see any particular advantage
> in a warning comment, so
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Thanks, applied to -misc

Sean

> -Chris
>
> --
> Chris Wilson, Intel Open Source Technology Centre
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index 706eea9..9ed4f9f 100644
--- a/drivers/dma-buf/sync_file.c
+++ b/drivers/dma-buf/sync_file.c
@@ -150,6 +150,7 @@  static int sync_file_set_fence(struct sync_file *sync_file,
 	 */
 	if (num_fences == 1) {
 		sync_file->fence = fences[0];
+		kfree(fences);
 	} else {
 		array = fence_array_create(num_fences, fences,
 					   fence_context_alloc(1), 1, false);