]> git.baikalelectronics.ru Git - kernel.git/commit
dma-buf: fix dma_buf_export init order v2
authorChristian König <christian.koenig@amd.com>
Tue, 6 Dec 2022 13:07:49 +0000 (14:07 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Jan 2023 06:24:30 +0000 (07:24 +0100)
commit6081ff3eb2fe9dbdf2af974d9c203e3e6be8b691
treeeb9ed5a0ed3d68a3b1a4ab693262a9ba36813b9a
parent396fbc01da89d71d3e73328fed0863f158294f0e
dma-buf: fix dma_buf_export init order v2

[ Upstream commit f728a5ea27c92133893590e731ce10f6561ced87 ]

The init order and resulting error handling in dma_buf_export
was pretty messy.

Subordinate objects like the file and the sysfs kernel objects
were initializing and wiring itself up with the object in the
wrong order resulting not only in complicating and partially
incorrect error handling, but also in publishing only halve
initialized DMA-buf objects.

Clean this up thoughtfully by allocating the file independent
of the DMA-buf object. Then allocate and initialize the DMA-buf
object itself, before publishing it through sysfs. If everything
works as expected the file is then connected with the DMA-buf
object and publish it through debugfs.

Also adds the missing dma_resv_fini() into the error handling.

v2: add some missing changes to dma_bug_getfile() and a missing NULL
    check in dma_buf_file_release()

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Reviewed-by: T.J. Mercier <tjmercier@google.com>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20221209071535.933698-1-christian.koenig@amd.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/dma-buf/dma-buf-sysfs-stats.c
drivers/dma-buf/dma-buf-sysfs-stats.h
drivers/dma-buf/dma-buf.c