History

tracing: Don't use the address of the buffer array name in copy_from_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

Wang Xiaoqiang committed 10 years ago

Commit 4afe6491 parent 6e4cf651 file · +3 −3Browse files

Showing the changes to kernel/trace (1 of 1 file). Show all

Unified · Split

kernel/trace/trace.c+3−3
@@ -3664,7 +3664,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf, · 3663 unmodified lines
36643664 if (cnt >= sizeof(buf))
36653665 return -EINVAL;
36663666
3667− if (copy_from_user(&buf, ubuf, cnt))
3667+ if (copy_from_user(buf, ubuf, cnt))
36683668 return -EFAULT;
36693669
36703670 buf[cnt] = 0;
@@ -4537,7 +4537,7 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, · 866 unmodified lines
45374537 if (cnt > MAX_TRACER_SIZE)
45384538 cnt = MAX_TRACER_SIZE;
45394539
4540− if (copy_from_user(&buf, ubuf, cnt))
4540+ if (copy_from_user(buf, ubuf, cnt))
45414541 return -EFAULT;
45424542
45434543 buf[cnt] = 0;
@@ -5327,7 +5327,7 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf, · 783 unmodified lines
53275327 if (cnt >= sizeof(buf))
53285328 return -EINVAL;
53295329
5330− if (copy_from_user(&buf, ubuf, cnt))
5330+ if (copy_from_user(buf, ubuf, cnt))
53315331 return -EFAULT;
53325332
53335333 buf[cnt] = 0;