ion: fix race condition in ion driver [1/1]

PD#SWPL-17365

Problem:
There are race condition between ion_client_destroy
and ion_debug_heap_show after adding memtrack function

Solution:
move debugfs_mutex to protect the ion_debug_heap_show

Verify:
autoreboot test on tl1

Change-Id: Ife30539426a003946db464bb7349746d991c6f36
Signed-off-by: binqi zhang <binqi.zhang@amlogic.com>
This commit is contained in:
binqi zhang
2019-12-10 21:25:05 +08:00
committed by Chris
parent 5221e9d5db
commit c543f0fd47

View File

@@ -1344,10 +1344,29 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused)
struct rb_node *n;
size_t total_size = 0;
size_t total_orphaned_size = 0;
#ifdef CONFIG_AMLOGIC_MODIFY
mutex_lock(&debugfs_mutex);
mutex_lock(&dev->buffer_lock);
seq_puts(s, "All allocated buffers listed:\n");
for (n = rb_first(&dev->buffers); n; n = rb_next(n)) {
struct ion_buffer *buffer = rb_entry(n, struct ion_buffer,
node);
if (buffer->heap->id != heap->id)
continue;
seq_printf(s, "%s %p %8s %u %8s %zu %8s %d %8s %d\n",
"buf=", buffer,
"heap_id=", heap->id,
"size=", buffer->size,
"kmap=", buffer->kmap_cnt,
"dmap=", buffer->dmap_cnt);
}
seq_puts(s, "----------------------------------------------------\n");
mutex_unlock(&dev->buffer_lock);
#else
seq_printf(s, "%16s %16s %16s\n", "client", "pid", "size");
seq_puts(s, "----------------------------------------------------\n");
mutex_lock(&debugfs_mutex);
#endif
for (n = rb_first(&dev->clients); n; n = rb_next(n)) {
struct ion_client *client = rb_entry(n, struct ion_client,
node);