Commit 3773b389 authored by Ian Munsie's avatar Ian Munsie Committed by Steven Rostedt

tracing/syscalls: Convert redundant syscall_nr checks into WARN_ON

With the ftrace events now checking if the syscall_nr is valid upon
initialisation it should no longer be possible to register or unregister
a syscall event without a valid syscall_nr since they should not be
created. This adds a WARN_ON_ONCE in the register and unregister
functions to locate potential regressions in the future.
Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
LKML-Reference: <1296703645-18718-3-git-send-email-imunsie@au1.ibm.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent ba976970
...@@ -359,7 +359,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call) ...@@ -359,7 +359,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
int num; int num;
num = ((struct syscall_metadata *)call->data)->syscall_nr; num = ((struct syscall_metadata *)call->data)->syscall_nr;
if (num < 0 || num >= NR_syscalls) if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
return -ENOSYS; return -ENOSYS;
mutex_lock(&syscall_trace_lock); mutex_lock(&syscall_trace_lock);
if (!sys_refcount_enter) if (!sys_refcount_enter)
...@@ -377,7 +377,7 @@ void unreg_event_syscall_enter(struct ftrace_event_call *call) ...@@ -377,7 +377,7 @@ void unreg_event_syscall_enter(struct ftrace_event_call *call)
int num; int num;
num = ((struct syscall_metadata *)call->data)->syscall_nr; num = ((struct syscall_metadata *)call->data)->syscall_nr;
if (num < 0 || num >= NR_syscalls) if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
return; return;
mutex_lock(&syscall_trace_lock); mutex_lock(&syscall_trace_lock);
sys_refcount_enter--; sys_refcount_enter--;
...@@ -393,7 +393,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call) ...@@ -393,7 +393,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
int num; int num;
num = ((struct syscall_metadata *)call->data)->syscall_nr; num = ((struct syscall_metadata *)call->data)->syscall_nr;
if (num < 0 || num >= NR_syscalls) if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
return -ENOSYS; return -ENOSYS;
mutex_lock(&syscall_trace_lock); mutex_lock(&syscall_trace_lock);
if (!sys_refcount_exit) if (!sys_refcount_exit)
...@@ -411,7 +411,7 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call) ...@@ -411,7 +411,7 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
int num; int num;
num = ((struct syscall_metadata *)call->data)->syscall_nr; num = ((struct syscall_metadata *)call->data)->syscall_nr;
if (num < 0 || num >= NR_syscalls) if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls))
return; return;
mutex_lock(&syscall_trace_lock); mutex_lock(&syscall_trace_lock);
sys_refcount_exit--; sys_refcount_exit--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment