68 lines
1.7 KiB
Diff
68 lines
1.7 KiB
Diff
|
From: David Herrmann <dh.herrmann@gmail.com>
|
||
|
Date: Mon, 20 Apr 2015 11:13:54 +0200
|
||
|
Subject: [PATCH] kdbus: no need to ref current->mm
|
||
|
|
||
|
If we access current->mm temporarily, there is no need to ref it. It can
|
||
|
only be changed by us, so no-one can race with us.
|
||
|
|
||
|
Avoid ref'ing and unref'ing it just to access some of its fields, similar
|
||
|
to what syscalls in mm/ do.
|
||
|
|
||
|
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
|
||
|
---
|
||
|
ipc/kdbus/metadata.c | 21 +++------------------
|
||
|
1 file changed, 3 insertions(+), 18 deletions(-)
|
||
|
|
||
|
diff --git a/ipc/kdbus/metadata.c b/ipc/kdbus/metadata.c
|
||
|
index a85eac34a5c4..c36b9cc67637 100644
|
||
|
--- a/ipc/kdbus/metadata.c
|
||
|
+++ b/ipc/kdbus/metadata.c
|
||
|
@@ -282,15 +282,10 @@ static void kdbus_meta_proc_collect_pid_comm(struct kdbus_meta_proc *mp)
|
||
|
|
||
|
static void kdbus_meta_proc_collect_exe(struct kdbus_meta_proc *mp)
|
||
|
{
|
||
|
- struct mm_struct *mm;
|
||
|
struct file *exe_file;
|
||
|
|
||
|
- mm = get_task_mm(current);
|
||
|
- if (!mm)
|
||
|
- return;
|
||
|
-
|
||
|
rcu_read_lock();
|
||
|
- exe_file = rcu_dereference(mm->exe_file);
|
||
|
+ exe_file = rcu_dereference(current->mm->exe_file);
|
||
|
if (exe_file) {
|
||
|
mp->exe_path = exe_file->f_path;
|
||
|
path_get(&mp->exe_path);
|
||
|
@@ -298,28 +293,18 @@ static void kdbus_meta_proc_collect_exe(struct kdbus_meta_proc *mp)
|
||
|
mp->valid |= KDBUS_ATTACH_EXE;
|
||
|
}
|
||
|
rcu_read_unlock();
|
||
|
-
|
||
|
- mmput(mm);
|
||
|
}
|
||
|
|
||
|
static int kdbus_meta_proc_collect_cmdline(struct kdbus_meta_proc *mp)
|
||
|
{
|
||
|
- struct mm_struct *mm;
|
||
|
+ struct mm_struct *mm = current->mm;
|
||
|
char *cmdline;
|
||
|
|
||
|
- mm = get_task_mm(current);
|
||
|
- if (!mm)
|
||
|
- return 0;
|
||
|
-
|
||
|
- if (!mm->arg_end) {
|
||
|
- mmput(mm);
|
||
|
+ if (!mm->arg_end)
|
||
|
return 0;
|
||
|
- }
|
||
|
|
||
|
cmdline = strndup_user((const char __user *)mm->arg_start,
|
||
|
mm->arg_end - mm->arg_start);
|
||
|
- mmput(mm);
|
||
|
-
|
||
|
if (IS_ERR(cmdline))
|
||
|
return PTR_ERR(cmdline);
|
||
|
|