Cleanup and preparation to simplify the next changes.

- Use current->tgid instead of current->group_leader->pid

- Use the value returned by get_task_struct() to initialize proc->tsk

Signed-off-by: Oleg Nesterov <[email protected]>
---
 drivers/android/binder.c       | 7 +++----
 drivers/android/binder_alloc.c | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index a3a1b5c33ba3..a00f6678f04d 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -6044,7 +6044,7 @@ static int binder_open(struct inode *nodp, struct file 
*filp)
        bool existing_pid = false;
 
        binder_debug(BINDER_DEBUG_OPEN_CLOSE, "%s: %d:%d\n", __func__,
-                    current->group_leader->pid, current->pid);
+                    current->tgid, current->pid);
 
        proc = kzalloc(sizeof(*proc), GFP_KERNEL);
        if (proc == NULL)
@@ -6053,8 +6053,8 @@ static int binder_open(struct inode *nodp, struct file 
*filp)
        dbitmap_init(&proc->dmap);
        spin_lock_init(&proc->inner_lock);
        spin_lock_init(&proc->outer_lock);
-       get_task_struct(current->group_leader);
-       proc->tsk = current->group_leader;
+       proc->tsk = get_task_struct(current->group_leader);
+       proc->pid = current->tgid;
        proc->cred = get_cred(filp->f_cred);
        INIT_LIST_HEAD(&proc->todo);
        init_waitqueue_head(&proc->freeze_wait);
@@ -6073,7 +6073,6 @@ static int binder_open(struct inode *nodp, struct file 
*filp)
        binder_alloc_init(&proc->alloc);
 
        binder_stats_created(BINDER_STAT_PROC);
-       proc->pid = current->group_leader->pid;
        INIT_LIST_HEAD(&proc->delivered_death);
        INIT_LIST_HEAD(&proc->delivered_freeze);
        INIT_LIST_HEAD(&proc->waiting_threads);
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 979c96b74cad..145ed5f14cdb 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -1233,7 +1233,7 @@ static struct shrinker *binder_shrinker;
 VISIBLE_IF_KUNIT void __binder_alloc_init(struct binder_alloc *alloc,
                                          struct list_lru *freelist)
 {
-       alloc->pid = current->group_leader->pid;
+       alloc->pid = current->tgid;
        alloc->mm = current->mm;
        mmgrab(alloc->mm);
        mutex_init(&alloc->mutex);
-- 
2.52.0

Reply via email to