Skip to contentSkip to conversation

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

PATCH Applied Gustavo Padovan 3 participants 3 messages Sep 21, 2016 – Sep 22, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

From: Gustavo Padovan <[email protected]>

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.

---
 drivers/dma-buf/sync_file.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dma-buf/sync_file.c +1 -0
index 706eea9..9ed4f9f 100644
@@ -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);
Signature · 6 lines
2.5.5

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Gustavo Padovan

From: Gustavo Padovan <[email protected]>

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.

---
 drivers/dma-buf/sync_file.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dma-buf/sync_file.c +0 -0
index 706eea9..9ed4f9f 100644

drivers/dma-buf/sync_file.c static int sync_file_set_fence(struct sync_file *sync_file, · line 153

Quoted 4 lines
drivers/dma-buf/sync_file.c +1 -0
@@ -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

-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Applied
#2 lore raw
Quoted 31 lines · Chris Wilson
Quoted 23 lines · Gustavo Padovan

From: Gustavo Padovan <[email protected]>

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.

---
 drivers/dma-buf/sync_file.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dma-buf/sync_file.c +0 -0
index 706eea9..9ed4f9f 100644

drivers/dma-buf/sync_file.c static int sync_file_set_fence(struct sync_file *sync_file, · line 153

Quoted 4 lines
drivers/dma-buf/sync_file.c +1 -0
@@ -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

Quoted 1 line

Thanks, applied to -misc

Sean

Quoted 8 lines

-Chris

--
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel