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
3664 if (cnt >= sizeof(buf))3664 if (cnt >= sizeof(buf))
3665 return -EINVAL;3665 return -EINVAL;
3666 3666
3667 if (copy_from_user(&buf, ubuf, cnt))3667 if (copy_from_user(buf, ubuf, cnt))
3668 return -EFAULT;3668 return -EFAULT;
3669 3669
3670 buf[cnt] = 0;3670 buf[cnt] = 0;
@@ -4537,7 +4537,7 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, · 866 unmodified lines
4537 if (cnt > MAX_TRACER_SIZE)4537 if (cnt > MAX_TRACER_SIZE)
4538 cnt = MAX_TRACER_SIZE;4538 cnt = MAX_TRACER_SIZE;
4539 4539
4540 if (copy_from_user(&buf, ubuf, cnt))4540 if (copy_from_user(buf, ubuf, cnt))
4541 return -EFAULT;4541 return -EFAULT;
4542 4542
4543 buf[cnt] = 0;4543 buf[cnt] = 0;
@@ -5327,7 +5327,7 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf, · 783 unmodified lines
5327 if (cnt >= sizeof(buf))5327 if (cnt >= sizeof(buf))
5328 return -EINVAL;5328 return -EINVAL;
5329 5329
5330 if (copy_from_user(&buf, ubuf, cnt))5330 if (copy_from_user(buf, ubuf, cnt))
5331 return -EFAULT;5331 return -EFAULT;
5332 5332
5333 buf[cnt] = 0;5333 buf[cnt] = 0;