Skip to content

Commit 54329e6

Browse files
owniasumitsemwal
authored andcommitted
dma-buf: cma_heap: Fix mutex locking section
Fix cma_heap_buffer mutex locking critical section to protect vmap_cnt and vaddr. Fixes: a5d2d29 ("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation") Signed-off-by: Weizhao Ouyang <[email protected]> Acked-by: John Stultz <[email protected]> Signed-off-by: Sumit Semwal <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 0499f41 commit 54329e6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/dma-buf/heaps/cma_heap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,11 @@ static int cma_heap_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
124124
struct cma_heap_buffer *buffer = dmabuf->priv;
125125
struct dma_heap_attachment *a;
126126

127+
mutex_lock(&buffer->lock);
128+
127129
if (buffer->vmap_cnt)
128130
invalidate_kernel_vmap_range(buffer->vaddr, buffer->len);
129131

130-
mutex_lock(&buffer->lock);
131132
list_for_each_entry(a, &buffer->attachments, list) {
132133
if (!a->mapped)
133134
continue;
@@ -144,10 +145,11 @@ static int cma_heap_dma_buf_end_cpu_access(struct dma_buf *dmabuf,
144145
struct cma_heap_buffer *buffer = dmabuf->priv;
145146
struct dma_heap_attachment *a;
146147

148+
mutex_lock(&buffer->lock);
149+
147150
if (buffer->vmap_cnt)
148151
flush_kernel_vmap_range(buffer->vaddr, buffer->len);
149152

150-
mutex_lock(&buffer->lock);
151153
list_for_each_entry(a, &buffer->attachments, list) {
152154
if (!a->mapped)
153155
continue;

0 commit comments

Comments
 (0)