Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1389347
| From | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [for-next][PATCH 5/5] tracing: Dont use the address of the buffer array name in copy_from_user |
| Date | 2016-04-27 18:40 +0200 |
| Message-ID | <rsAFk-4bo-19@gated-at.bofh.it> (permalink) |
| References | <rsAFk-4bo-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Wang Xiaoqiang <wangxq10@lzu.edu.cn>
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>
---
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 5e3ad3481e4b..46028d47d252 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -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;
@@ -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;
@@ -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;
--
2.8.0.rc3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[for-next][PATCH 0/5] tracing: More updates for 4.7 Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200 [for-next][PATCH 3/5] tracing: Add check for NULL event field when creating hist field Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200 [for-next][PATCH 5/5] tracing: Dont use the address of the buffer array name in copy_from_user Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200 [for-next][PATCH 2/5] tracing: checking for NULL instead of IS_ERR() Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200 [for-next][PATCH 4/5] tracing: Handle tracing_map_alloc_elts() error path correctly Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200 [for-next][PATCH 1/5] tracing: Do not inherit event-fork option for instances Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200
csiph-web