[PATCH 2/2] trace_syscalls: cleanup: check syscall_nr with syscall_nr_to_meta

From: Dmitry Safonov
Date: Fri Nov 20 2015 - 07:02:41 EST


As syscall_nr_to_meta already checks for
(syscall_nr < 0 || syscall_nr >= NR_syscalls) - remove this checkups.

Signed-off-by: Dmitry Safonov <0x7f454c46@xxxxxxxxx>
---
kernel/trace/trace_syscalls.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index b9d4c3cc60aeba..7dc58306de1a3f 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -305,7 +305,8 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
int size;

syscall_nr = trace_get_syscall_nr(current, regs);
- if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
+ sys_data = syscall_nr_to_meta(syscall_nr);
+ if (!sys_data)
return;

/* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE) */
@@ -316,10 +317,6 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
if (trace_trigger_soft_disabled(trace_file))
return;

- sys_data = syscall_nr_to_meta(syscall_nr);
- if (!sys_data)
- return;
-
size = sizeof(*entry) + sizeof(unsigned long) * sys_data->nb_args;

local_save_flags(irq_flags);
@@ -352,7 +349,8 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
int syscall_nr;

syscall_nr = trace_get_syscall_nr(current, regs);
- if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
+ sys_data = syscall_nr_to_meta(syscall_nr);
+ if (!sys_data)
return;

/* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE()) */
@@ -363,10 +361,6 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
if (trace_trigger_soft_disabled(trace_file))
return;

- sys_data = syscall_nr_to_meta(syscall_nr);
- if (!sys_data)
- return;
-
local_save_flags(irq_flags);
pc = preempt_count();

@@ -556,15 +550,13 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
int size;

syscall_nr = trace_get_syscall_nr(current, regs);
- if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
- return;
- if (!test_bit(syscall_nr, enabled_perf_enter_syscalls))
- return;
-
sys_data = syscall_nr_to_meta(syscall_nr);
if (!sys_data)
return;

+ if (!test_bit(syscall_nr, enabled_perf_enter_syscalls))
+ return;
+
head = this_cpu_ptr(sys_data->enter_event->perf_events);
if (hlist_empty(head))
return;
@@ -630,15 +622,13 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
int size;

syscall_nr = trace_get_syscall_nr(current, regs);
- if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
- return;
- if (!test_bit(syscall_nr, enabled_perf_exit_syscalls))
- return;
-
sys_data = syscall_nr_to_meta(syscall_nr);
if (!sys_data)
return;

+ if (!test_bit(syscall_nr, enabled_perf_exit_syscalls))
+ return;
+
head = this_cpu_ptr(sys_data->exit_event->perf_events);
if (hlist_empty(head))
return;
--
2.6.2

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