[PATCH 06/13] android: binder: add function to find target binder node

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pull the logic that determines the target_node of a transaction into a
dedicated function.

Signed-off-by: Riley Andrews <riandrews@xxxxxxxxxxx>
---
 drivers/android/binder.c | 46 +++++++++++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 407c1ee..99a3270 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -1536,6 +1536,29 @@ error:
 	return result;
 }
 
+static int binder_get_tr_target_node(struct binder_thread *thread,
+				     struct binder_transaction_data *tr,
+				     struct binder_node **target_node)
+{
+	struct binder_proc *proc = thread->proc;
+	struct binder_ref *ref;
+
+	if (tr->target.handle) {
+		ref = binder_get_ref(proc, tr->target.handle);
+		if (!ref) {
+			binder_user_error("%d:%d got transaction to invalid handle\n",
+					  proc->pid, thread->pid);
+			return BR_FAILED_REPLY;
+		}
+		*target_node = ref->node;
+	} else {
+		*target_node = binder_context_mgr_node;
+		if (!(*target_node))
+			return BR_DEAD_REPLY;
+	}
+	return BR_OK;
+}
+
 static void binder_transaction(struct binder_thread *thread,
 			       struct binder_transaction_data *tr, int reply)
 {
@@ -1599,24 +1622,10 @@ static void binder_transaction(struct binder_thread *thread,
 		}
 		target_proc = target_thread->proc;
 	} else {
-		if (tr->target.handle) {
-			struct binder_ref *ref;
-
-			ref = binder_get_ref(proc, tr->target.handle);
-			if (ref == NULL) {
-				binder_user_error("%d:%d got transaction to invalid handle\n",
-					proc->pid, thread->pid);
-				return_error = BR_FAILED_REPLY;
-				goto err_invalid_target_handle;
-			}
-			target_node = ref->node;
-		} else {
-			target_node = binder_context_mgr_node;
-			if (target_node == NULL) {
-				return_error = BR_DEAD_REPLY;
-				goto err_no_context_mgr_node;
-			}
-		}
+		return_error = binder_get_tr_target_node(thread, tr,
+							 &target_node);
+		if (return_error != BR_OK)
+			goto err_invalid_target_handle;
 		e->to_node = target_node->debug_id;
 		target_proc = target_node->proc;
 		if (target_proc == NULL) {
@@ -1780,7 +1789,6 @@ err_bad_call_stack:
 err_empty_call_stack:
 err_dead_binder:
 err_invalid_target_handle:
-err_no_context_mgr_node:
 	binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
 		     "%d:%d transaction failed %d, size %lld-%lld\n",
 		     proc->pid, thread->pid, return_error,
-- 
2.2.0.rc0.207.ga3a616c

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux