summaryrefslogtreecommitdiff
path: root/lwis_buffer.c
diff options
context:
space:
mode:
authorNick Chung <nickchung@google.com>2024-03-22 07:51:48 +0000
committerTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-03-27 01:59:05 +0000
commit0b0207160031d72c4cffb717032f3864bd030f0e (patch)
tree706ce37861400340db5d042a9ccf045da01b6e24 /lwis_buffer.c
parente0794ba1e0db501703ec35e65d7cf332fa5e0af1 (diff)
downloadlwis-0b0207160031d72c4cffb717032f3864bd030f0e.tar.gz
Accessing enrolled buffers from multiple clients is only protected by a spinlock, which is a potential risk. We should add a lock to protect the buffer access process on multiple LWIS clients because it could be modified by other processes, such as the disenroll buffer and delete list processes. Bug: 330457969 Test: CTS, GCA SMOKE Change-Id: Ib81f95e45afca6638b51cc0dc423561cabfdea7d Signed-off-by: Nick Chung <nickchung@google.com> (cherry picked from commit 155aaf52ceb09cbd0765e5c0419d9576969e7389)
Diffstat (limited to 'lwis_buffer.c')
-rw-r--r--lwis_buffer.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lwis_buffer.c b/lwis_buffer.c
index 69b51b6..988afd1 100644
--- a/lwis_buffer.c
+++ b/lwis_buffer.c
@@ -71,13 +71,16 @@ static void dump_total_enrolled_buffer_size(struct lwis_device *lwis_dev)
continue;
}
hash_for_each (client->enrolled_buffers, i, enrollment_list, node) {
+ spin_lock_irqsave(&client->buffer_lock, flags);
buffer = list_first_entry(&enrollment_list->list,
struct lwis_enrolled_buffer, list_node);
total_enrolled_size += buffer->dma_buf->size;
num_enrolled_buffers++;
+ spin_unlock_irqrestore(&client->buffer_lock, flags);
}
}
spin_unlock_irqrestore(&lwis_dev->lock, flags);
+
if (total_enrolled_size > 0) {
pr_info("%-16s: %16d %16lu kB\n", lwis_dev->name, num_enrolled_buffers,
total_enrolled_size / 1024);