Skip to content

Commit 1909a67

Browse files
Todd Kjosgregkh
authored andcommitted
binder: fix memory leak in error path
syzkallar found a 32-byte memory leak in a rarely executed error case. The transaction complete work item was not freed if put_user() failed when writing the BR_TRANSACTION_COMPLETE to the user command buffer. Fixed by freeing it before put_user() is called. Reported-by: syzbot+182ce46596c3f2e1eb24@syzkaller.appspotmail.com Signed-off-by: Todd Kjos <tkjos@google.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 21f010b commit 1909a67

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/android/binder.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4256,6 +4256,8 @@ static int binder_thread_read(struct binder_proc *proc,
42564256
case BINDER_WORK_TRANSACTION_COMPLETE: {
42574257
binder_inner_proc_unlock(proc);
42584258
cmd = BR_TRANSACTION_COMPLETE;
4259+
kfree(w);
4260+
binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
42594261
if (put_user(cmd, (uint32_t __user *)ptr))
42604262
return -EFAULT;
42614263
ptr += sizeof(uint32_t);
@@ -4264,8 +4266,6 @@ static int binder_thread_read(struct binder_proc *proc,
42644266
binder_debug(BINDER_DEBUG_TRANSACTION_COMPLETE,
42654267
"%d:%d BR_TRANSACTION_COMPLETE\n",
42664268
proc->pid, thread->pid);
4267-
kfree(w);
4268-
binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
42694269
} break;
42704270
case BINDER_WORK_NODE: {
42714271
struct binder_node *node = container_of(w, struct binder_node, work);

0 commit comments

Comments
 (0)