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

Signed-off-by: Riley Andrews <riandr...@android.com>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to