diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 366b12405708187e0116337a4a316cdec45fb9d3..b9985eee8c1bc536fbf6868167ef5ba809bb0844 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -1744,6 +1744,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)
 		/*