]> git.baikalelectronics.ru Git - kernel.git/commit
dma-buf: fix racing conflict of dma_heap_add()
authorDawei Li <set_pte_at@outlook.com>
Fri, 4 Nov 2022 16:05:36 +0000 (00:05 +0800)
committerSumit Semwal <sumit.semwal@linaro.org>
Tue, 22 Nov 2022 12:57:56 +0000 (18:27 +0530)
commit1beeb5154d7c4986c2916b494a6f1fc5423985f8
treebf5e6a786ea8732887a9353820ae872fc8cefef2
parent90725a6ef56f0536464febea8cf07225ac5d5471
dma-buf: fix racing conflict of dma_heap_add()

Racing conflict could be:
task A                 task B
list_for_each_entry
strcmp(h->name))
                       list_for_each_entry
                       strcmp(h->name)
kzalloc                kzalloc
......                 .....
device_create          device_create
list_add
                       list_add

The root cause is that task B has no idea about the fact someone
else(A) has inserted heap with same name when it calls list_add,
so a potential collision occurs.

Fixes: a33aa79cd159 ("dma-buf: Add dma-buf heaps framework")
Signed-off-by: Dawei Li <set_pte_at@outlook.com>
Acked-by: Andrew Davis <afd@ti.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/TYCP286MB2323873BBDF88020781FB986CA3B9@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM
drivers/dma-buf/dma-heap.c