Skip to contentSkip to conversation

tracing: cleanup for tracing_trace_options_read()

PATCH In review Xiao Guangrong 2 participants 3 messages Jun 22, 2009 – Aug 5, 2009 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: cleanup for tracing_trace_options_read()

'\n' is already appended, and what we need is just an extra space for the '\0'.

---
 kernel/trace/trace.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace.c +3 -3
index 076fa6f..4c3f856 100644
@@ -2266,8 +2266,8 @@ tracing_trace_options_read(struct file *filp, char __user *ubuf,
 		len += 3; /* "no" and newline */
 	}
 
-	/* +2 for \n and \0 */
-	buf = kmalloc(len + 2, GFP_KERNEL);
+	/* +1 for \0 */
+	buf = kmalloc(len + 1, GFP_KERNEL);
 	if (!buf) {
 		mutex_unlock(&trace_types_lock);
 		return -ENOMEM;
@@ -2290,7 +2290,7 @@ tracing_trace_options_read(struct file *filp, char __user *ubuf,
 	}
 	mutex_unlock(&trace_types_lock);
 
-	WARN_ON(r >= len + 2);
+	WARN_ON(r >= len + 1);
 
 	r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
 
Signature · 1 line
1.6.1.2
maintainer
#1 lore raw
Quoted 2 lines · Xiao Guangrong

'\n' is already appended, and what we need is just an extra space for the '\0'.

Hi Xiao,

I'm going through old email (or email lost in the shuffle) and I came across this lost patch. I'll go ahead an apply it.

Thanks,

-- Steve

Quoted 34 lines
---
 kernel/trace/trace.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace.c +3 -3
index 076fa6f..4c3f856 100644
@@ -2266,8 +2266,8 @@ tracing_trace_options_read(struct file *filp, char __user *ubuf,
 		len += 3; /* "no" and newline */
 	}
 
-	/* +2 for \n and \0 */
-	buf = kmalloc(len + 2, GFP_KERNEL);
+	/* +1 for \0 */
+	buf = kmalloc(len + 1, GFP_KERNEL);
 	if (!buf) {
 		mutex_unlock(&trace_types_lock);
 		return -ENOMEM;
@@ -2290,7 +2290,7 @@ tracing_trace_options_read(struct file *filp, char __user *ubuf,
 	}
 	mutex_unlock(&trace_types_lock);
 
-	WARN_ON(r >= len + 2);
+	WARN_ON(r >= len + 1);
 
 	r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
 
Signature · 1 line
1.6.1.2
#2 lore raw
In reply to Xiao Guangrong
Commit-ID:  ff4e9da2330beb8d64498a513d3f9694e941b01a
Gitweb:     http://git.kernel.org/tip/ff4e9da2330beb8d64498a513d3f9694e941b01a
Author:     Xiao Guangrong <[email protected]>
AuthorDate: Mon, 22 Jun 2009 10:33:07 +0800
Committer:  Steven Rostedt <[email protected]>
CommitDate: Mon, 20 Jul 2009 12:02:09 -0400

tracing: cleanup for tracing_trace_options_read()

'\n' is already appended, and what we need is just an extra space for the '\0'.

LKML-Reference: <[email protected]>

---
 kernel/trace/trace.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace.c +3 -3
index e30e6b1..38a4a3e 100644
@@ -2256,8 +2256,8 @@ tracing_trace_options_read(struct file *filp, char __user *ubuf,
 		len += 3; /* "no" and newline */
 	}
 
-	/* +2 for \n and \0 */
-	buf = kmalloc(len + 2, GFP_KERNEL);
+	/* +1 for \0 */
+	buf = kmalloc(len + 1, GFP_KERNEL);
 	if (!buf) {
 		mutex_unlock(&trace_types_lock);
 		return -ENOMEM;
@@ -2280,7 +2280,7 @@ tracing_trace_options_read(struct file *filp, char __user *ubuf,
 	}
 	mutex_unlock(&trace_types_lock);
 
-	WARN_ON(r >= len + 2);
+	WARN_ON(r >= len + 1);
 
 	r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);