diff options
Diffstat (limited to 'drivers/android')
| -rw-r--r-- | drivers/android/binder.c | 12 | ||||
| -rw-r--r-- | drivers/android/binder_alloc.c | 4 | 
2 files changed, 14 insertions, 2 deletions
| diff --git a/drivers/android/binder.c b/drivers/android/binder.c index c964d7c8c384..6428f6be69e3 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -1385,6 +1385,18 @@ static int binder_inc_ref_for_node(struct binder_proc *proc,  	}  	ret = binder_inc_ref_olocked(ref, strong, target_list);  	*rdata = ref->data; +	if (ret && ref == new_ref) { +		/* +		 * Cleanup the failed reference here as the target +		 * could now be dead and have already released its +		 * references by now. Calling on the new reference +		 * with strong=0 and a tmp_refs will not decrement +		 * the node. The new_ref gets kfree'd below. +		 */ +		binder_cleanup_ref_olocked(new_ref); +		ref = NULL; +	} +  	binder_proc_unlock(proc);  	if (new_ref && ref != new_ref)  		/* diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c index 51f4e1c5cd01..9b1778c00610 100644 --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c @@ -322,7 +322,6 @@ static inline void binder_alloc_set_vma(struct binder_alloc *alloc,  	 */  	if (vma) {  		vm_start = vma->vm_start; -		alloc->vma_vm_mm = vma->vm_mm;  		mmap_assert_write_locked(alloc->vma_vm_mm);  	} else {  		mmap_assert_locked(alloc->vma_vm_mm); @@ -795,7 +794,6 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,  	binder_insert_free_buffer(alloc, buffer);  	alloc->free_async_space = alloc->buffer_size / 2;  	binder_alloc_set_vma(alloc, vma); -	mmgrab(alloc->vma_vm_mm);  	return 0; @@ -1091,6 +1089,8 @@ static struct shrinker binder_shrinker = {  void binder_alloc_init(struct binder_alloc *alloc)  {  	alloc->pid = current->group_leader->pid; +	alloc->vma_vm_mm = current->mm; +	mmgrab(alloc->vma_vm_mm);  	mutex_init(&alloc->mutex);  	INIT_LIST_HEAD(&alloc->buffers);  } | 
