]> git.baikalelectronics.ru Git - kernel.git/commit
dma-buf/sync_file: Don't leak fences on merge failure
authorJason Ekstrand <jason@jlekstrand.net>
Thu, 24 Jun 2021 17:47:32 +0000 (12:47 -0500)
committerChristian König <christian.koenig@amd.com>
Mon, 12 Jul 2021 11:34:49 +0000 (13:34 +0200)
commit2ba5e1d42f3c284a066784fdbcca240da18c8e1f
treedb4fdd7ea3cb5c22f6107a66b619c6c725990d2e
parent0614e47e78ff7d34bee1d3f0a87f2d025410209f
dma-buf/sync_file: Don't leak fences on merge failure

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: 5f920a217aa0 ("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>
drivers/dma-buf/sync_file.c