linux-stable/drivers/dma-buf
Jason Ekstrand 19f51c2529 dma-buf/sync_file: Don't leak fences on merge failure
commit ffe000217c upstream.

Each add_fence() call does a dma_fence_get() on the relevant fence.  In
the error path, we weren't calling dma_fence_put() so all those fences
got leaked.  Also, in the krealloc_array failure case, we weren't
freeing the fences array.  Instead, ensure that i and fences are always
zero-initialized and dma_fence_put() all the fences and kfree(fences) on
every error path.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Christian König <christian.koenig@amd.com>
Fixes: a02b9dc90d ("dma-buf/sync_file: refactor fence storage in struct sync_file")
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Cc: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210624174732.1754546-1-jason@jlekstrand.net
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-28 11:12:16 +02:00
..
dma-buf.c dma-buf: balance refcount inbalance 2019-07-31 07:28:47 +02:00
dma-fence-array.c dma-buf/fence: Fix lock inversion within dma-fence-array 2018-03-19 08:42:47 +01:00
dma-fence.c Linux 4.13-rc2 2017-07-27 08:15:43 +10:00
Kconfig dma-buf: Rename struct fence to dma_fence 2016-10-25 14:40:39 +02:00
Makefile dma-buf: Rename struct fence to dma_fence 2016-10-25 14:40:39 +02:00
reservation.c dma-buf: Discard old fence_excl on retrying get_fences_rcu for realloc 2019-07-31 07:28:47 +02:00
seqno-fence.c dma-buf: Rename struct fence to dma_fence 2016-10-25 14:40:39 +02:00
sw_sync.c dma-buf/sw_sync: Synchronize signal vs syncpt free 2019-10-07 18:55:07 +02:00
sync_debug.c Linux 4.13-rc2 2017-07-27 08:15:43 +10:00
sync_debug.h dma-buf/sw-sync: Use an rbtree to sort fences in the timeline 2017-06-29 18:54:07 -03:00
sync_file.c dma-buf/sync_file: Don't leak fences on merge failure 2021-07-28 11:12:16 +02:00
sync_trace.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00