Эх сурвалжийг харах

ftrace: replace simple_strtoul with strict_strtoul

Andrew Morton suggested using strict_strtoul over simple_strtoul.
This patch replaces them in ftrace.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Steven Rostedt 17 жил өмнө
parent
commit
c6caeeb142

+ 22 - 6
kernel/trace/trace.c

@@ -92,9 +92,16 @@ void trace_wake_up(void)
 
 
 static int __init set_nr_entries(char *str)
 static int __init set_nr_entries(char *str)
 {
 {
+	unsigned long nr_entries;
+	int ret;
+
 	if (!str)
 	if (!str)
 		return 0;
 		return 0;
-	trace_nr_entries = simple_strtoul(str, &str, 0);
+	ret = strict_strtoul(str, 0, &nr_entries);
+	/* nr_entries can not be zero */
+	if (ret < 0 || nr_entries == 0)
+		return 0;
+	trace_nr_entries = nr_entries;
 	return 1;
 	return 1;
 }
 }
 __setup("trace_entries=", set_nr_entries);
 __setup("trace_entries=", set_nr_entries);
@@ -1995,8 +2002,9 @@ tracing_ctrl_write(struct file *filp, const char __user *ubuf,
 		   size_t cnt, loff_t *ppos)
 		   size_t cnt, loff_t *ppos)
 {
 {
 	struct trace_array *tr = filp->private_data;
 	struct trace_array *tr = filp->private_data;
-	long val;
 	char buf[64];
 	char buf[64];
+	long val;
+	int ret;
 
 
 	if (cnt >= sizeof(buf))
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 		return -EINVAL;
@@ -2006,7 +2014,9 @@ tracing_ctrl_write(struct file *filp, const char __user *ubuf,
 
 
 	buf[cnt] = 0;
 	buf[cnt] = 0;
 
 
-	val = simple_strtoul(buf, NULL, 10);
+	ret = strict_strtoul(buf, 10, &val);
+	if (ret < 0)
+		return ret;
 
 
 	val = !!val;
 	val = !!val;
 
 
@@ -2110,8 +2120,9 @@ tracing_max_lat_write(struct file *filp, const char __user *ubuf,
 		      size_t cnt, loff_t *ppos)
 		      size_t cnt, loff_t *ppos)
 {
 {
 	long *ptr = filp->private_data;
 	long *ptr = filp->private_data;
-	long val;
 	char buf[64];
 	char buf[64];
+	long val;
+	int ret;
 
 
 	if (cnt >= sizeof(buf))
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 		return -EINVAL;
@@ -2121,7 +2132,9 @@ tracing_max_lat_write(struct file *filp, const char __user *ubuf,
 
 
 	buf[cnt] = 0;
 	buf[cnt] = 0;
 
 
-	val = simple_strtoul(buf, NULL, 10);
+	ret = strict_strtoul(buf, 10, &val);
+	if (ret < 0)
+		return ret;
 
 
 	*ptr = val * 1000;
 	*ptr = val * 1000;
 
 
@@ -2376,6 +2389,7 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
 {
 {
 	unsigned long val;
 	unsigned long val;
 	char buf[64];
 	char buf[64];
+	int ret;
 
 
 	if (cnt >= sizeof(buf))
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 		return -EINVAL;
@@ -2385,7 +2399,9 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
 
 
 	buf[cnt] = 0;
 	buf[cnt] = 0;
 
 
-	val = simple_strtoul(buf, NULL, 10);
+	ret = strict_strtoul(buf, 10, &val);
+	if (ret < 0)
+		return ret;
 
 
 	/* must have at least 1 entry */
 	/* must have at least 1 entry */
 	if (!val)
 	if (!val)