[PATCH] tracing: Don't use the address of the buffer array name in copy_from_user

From: Wang Xiaoqiang
Date: Mon Apr 18 2016 - 02:58:15 EST


Fix the problem as follows:

...
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" replace "&buf".

Signed-off-by: Wang Xiaoqiang <wangxq10@xxxxxxxxxx>
---
kernel/trace/trace.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a2f0b9f..422ab57 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3658,7 +3658,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;
@@ -4474,7 +4474,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;
@@ -5264,7 +5264,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;
--
2.1.4