From: "Arve Hjønnevåg" <arve@android.com>
To: gregkh@linuxfoundation.org
Cc: xiaobing.tu@intel.com, ccross@android.com, davej@redhat.com,
akpm@linux-foundation.org, mingo@elte.hu, rusty@rustcorp.com.au,
a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org,
rostedt@goodmis.org, di.zhang@intel.com, xindong.ma@intel.com,
alex.zuo@intel.com, "Arve Hjønnevåg" <arve@android.com>
Subject: [PATCH 3/4] Staging: android: binder: Fix memory leak on thread/process exit
Date: Tue, 16 Oct 2012 15:29:54 -0700 [thread overview]
Message-ID: <1350426595-18059-3-git-send-email-arve@android.com> (raw)
In-Reply-To: <1350426595-18059-1-git-send-email-arve@android.com>
If a thread or process exited while a reply, one-way transaction or
death notification was pending, the struct holding the pending work
was leaked.
Signed-off-by: Arve Hjønnevåg <arve@android.com>
---
drivers/staging/android/binder.c | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index b7cfcdb..91ce956 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -2460,14 +2460,38 @@ static void binder_release_work(struct list_head *list)
struct binder_transaction *t;
t = container_of(w, struct binder_transaction, work);
- if (t->buffer->target_node && !(t->flags & TF_ONE_WAY))
+ if (t->buffer->target_node &&
+ !(t->flags & TF_ONE_WAY)) {
binder_send_failed_reply(t, BR_DEAD_REPLY);
+ } else {
+ binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
+ "binder: undelivered transaction %d\n",
+ t->debug_id);
+ t->buffer->transaction = NULL;
+ kfree(t);
+ binder_stats_deleted(BINDER_STAT_TRANSACTION);
+ }
} break;
case BINDER_WORK_TRANSACTION_COMPLETE: {
+ binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
+ "binder: undelivered TRANSACTION_COMPLETE\n");
kfree(w);
binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
} break;
+ case BINDER_WORK_DEAD_BINDER_AND_CLEAR:
+ case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: {
+ struct binder_ref_death *death;
+
+ death = container_of(w, struct binder_ref_death, work);
+ binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
+ "binder: undelivered death notification, %p\n",
+ death->cookie);
+ kfree(death);
+ binder_stats_deleted(BINDER_STAT_DEATH);
+ } break;
default:
+ pr_err("binder: unexpected work type, %d, not freed\n",
+ w->type);
break;
}
}
@@ -2951,6 +2975,7 @@ static void binder_deferred_release(struct binder_proc *proc)
nodes++;
rb_erase(&node->rb_node, &proc->nodes);
list_del_init(&node->work.entry);
+ binder_release_work(&node->async_todo);
if (hlist_empty(&node->refs)) {
kfree(node);
binder_stats_deleted(BINDER_STAT_NODE);
@@ -2989,6 +3014,7 @@ static void binder_deferred_release(struct binder_proc *proc)
binder_delete_ref(ref);
}
binder_release_work(&proc->todo);
+ binder_release_work(&proc->delivered_death);
buffers = 0;
while ((n = rb_first(&proc->allocated_buffers))) {
--
1.7.7.3
next prev parent reply other threads:[~2012-10-16 22:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-15 7:03 Fix memory leak in binder Tu, Xiaobing
2012-10-15 7:20 ` Fix memory leak in binder--version2 Tu, Xiaobing
2012-10-15 22:52 ` Greg KH
2012-10-15 23:55 ` Arve Hjønnevåg
2012-10-15 23:58 ` Greg KH
2012-10-16 0:32 ` [PATCH 1/2] Staging: android: binder: Fix memory leak on thread/process exit Arve Hjønnevåg
2012-10-16 0:32 ` [PATCH 2/2] Staging: android: binder: Allow using highmem for binder buffers Arve Hjønnevåg
2012-10-16 7:12 ` Greg KH
2012-10-16 7:11 ` [PATCH 1/2] Staging: android: binder: Fix memory leak on thread/process exit Greg KH
2012-10-16 22:45 ` Arve Hjønnevåg
2012-10-22 20:00 ` Greg KH
2012-10-23 0:58 ` Arve Hjønnevåg
2012-10-23 3:12 ` Greg KH
2012-10-16 0:39 ` Fix memory leak in binder--version2 Arve Hjønnevåg
2012-10-16 7:11 ` Greg KH
2012-10-16 22:29 ` [PATCH 1/4] Staging: android: binder: Add some missing binder_stat_br calls Arve Hjønnevåg
2012-10-16 22:29 ` [PATCH 2/4] Staging: android: binder: Add some tracepoints Arve Hjønnevåg
2012-10-16 22:29 ` Arve Hjønnevåg [this message]
2012-10-16 22:29 ` [PATCH 4/4] Staging: android: binder: Allow using highmem for binder buffers Arve Hjønnevåg
2012-10-16 22:33 ` Fix memory leak in binder--version2 Arve Hjønnevåg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1350426595-18059-3-git-send-email-arve@android.com \
--to=arve@android.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=alex.zuo@intel.com \
--cc=ccross@android.com \
--cc=davej@redhat.com \
--cc=di.zhang@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
--cc=xiaobing.tu@intel.com \
--cc=xindong.ma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome