Skip to content

Commit

Permalink
tracing: Don't use the address of the buffer array name in copy_from_…
Browse files Browse the repository at this point in the history
…user

With the following code snippet:

    ...
    char buf[64];
    ...
    if (copy_from_user(&buf, ubuf, cnt))
    ...

Even though the value of "&buf" equals "buf", but there is no need
to get the address of the "buf" again. Use "buf" instead of "&buf".

Link: http://lkml.kernel.org/r/20160418152329.18b72bea@debian

Signed-off-by: Wang Xiaoqiang <wangxq10@lzu.edu.cn>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Wang Xiaoqiang authored and Steven Rostedt committed Apr 26, 2016
1 parent 6e4cf65 commit 4afe649
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -3664,7 +3664,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
if (cnt >= sizeof(buf))
return -EINVAL;

if (copy_from_user(&buf, ubuf, cnt))
if (copy_from_user(buf, ubuf, cnt))
return -EFAULT;

buf[cnt] = 0;
Expand Down Expand Up @@ -4537,7 +4537,7 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
if (cnt > MAX_TRACER_SIZE)
cnt = MAX_TRACER_SIZE;

if (copy_from_user(&buf, ubuf, cnt))
if (copy_from_user(buf, ubuf, cnt))
return -EFAULT;

buf[cnt] = 0;
Expand Down Expand Up @@ -5327,7 +5327,7 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
if (cnt >= sizeof(buf))
return -EINVAL;

if (copy_from_user(&buf, ubuf, cnt))
if (copy_from_user(buf, ubuf, cnt))
return -EFAULT;

buf[cnt] = 0;
Expand Down

0 comments on commit 4afe649

Please sign in to comment.