mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
binder: fix memory leak [1/1]
PD#TV-3541 Problem: 1.only vmalloc 4KB at first. 2.if user space need more memory, try to allocate a new vmalloc range with large size and move all related data to new place. 3.the first 4KB is not free when release this binder. Solution: free the first 4KB when release binder. Verify: R311 Change-Id: I4429de04a260671e4626b77ec340e47e436d5c8d Signed-off-by: changqing.gao <changqing.gao@amlogic.com>
This commit is contained in:
@@ -838,6 +838,9 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
|
||||
goto err_get_vm_area_failed;
|
||||
}
|
||||
alloc->buffer = area->addr;
|
||||
#ifdef CONFIG_AMLOGIC_BINDER_VMALLOC
|
||||
alloc->first_addr = area->addr;
|
||||
#endif
|
||||
alloc->user_buffer_offset =
|
||||
vma->vm_start - (uintptr_t)alloc->buffer;
|
||||
mutex_unlock(&binder_alloc_mmap_lock);
|
||||
@@ -958,6 +961,8 @@ void binder_alloc_deferred_release(struct binder_alloc *alloc)
|
||||
vfree(alloc->buffer);
|
||||
#ifdef CONFIG_AMLOGIC_BINDER_VMALLOC
|
||||
free_back_buffer(alloc);
|
||||
if (alloc->first_addr && alloc->first_addr != alloc->buffer)
|
||||
vfree(alloc->first_addr);
|
||||
#endif
|
||||
}
|
||||
mutex_unlock(&alloc->mutex);
|
||||
|
||||
@@ -113,6 +113,7 @@ struct binder_alloc {
|
||||
#ifdef CONFIG_AMLOGIC_BINDER_VMALLOC
|
||||
size_t mapped_size;
|
||||
void *back_buffer[MAX_BUFFER];
|
||||
void *first_addr;
|
||||
#endif /* CONFIG_AMLOGIC_BINDER_VMALLOC */
|
||||
ptrdiff_t user_buffer_offset;
|
||||
struct list_head buffers;
|
||||
|
||||
Reference in New Issue
Block a user