Commit d954fbf0 authored by Thomas Gleixner's avatar Thomas Gleixner

tracing: Fix wrong usage of strstrip in trace_ksyms

strstrip returns a pointer to the first non space character, but the
code in parse_ksym_trace_str() ignores that.

strstrip is now must_check and therefor we get the correct warning:
kernel/trace/trace_ksym.c:294: warning:
ignoring return value of ‘strstrip’, declared with attribute warn_unused_result

We are really not interested in leading whitespace here.

Fix that and cleanup the dozen kfree() exit pathes.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
parent 788d70dc
...@@ -277,21 +277,20 @@ static ssize_t ksym_trace_filter_write(struct file *file, ...@@ -277,21 +277,20 @@ static ssize_t ksym_trace_filter_write(struct file *file,
{ {
struct trace_ksym *entry; struct trace_ksym *entry;
struct hlist_node *node; struct hlist_node *node;
char *input_string, *ksymname = NULL; char *buf, *input_string, *ksymname = NULL;
unsigned long ksym_addr = 0; unsigned long ksym_addr = 0;
int ret, op, changed = 0; int ret, op, changed = 0;
input_string = kzalloc(count + 1, GFP_KERNEL); buf = kzalloc(count + 1, GFP_KERNEL);
if (!input_string) if (!buf)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(input_string, buffer, count)) { ret = -EFAULT;
kfree(input_string); if (copy_from_user(buf, buffer, count))
return -EFAULT; goto out;
}
input_string[count] = '\0';
strstrip(input_string); buf[count] = '\0';
input_string = strstrip(buf);
/* /*
* Clear all breakpoints if: * Clear all breakpoints if:
...@@ -302,15 +301,13 @@ static ssize_t ksym_trace_filter_write(struct file *file, ...@@ -302,15 +301,13 @@ static ssize_t ksym_trace_filter_write(struct file *file,
if (!input_string[0] || !strcmp(input_string, "0") || if (!input_string[0] || !strcmp(input_string, "0") ||
!strcmp(input_string, "*:---")) { !strcmp(input_string, "*:---")) {
__ksym_trace_reset(); __ksym_trace_reset();
kfree(input_string); ret = 0;
return count; goto out;
} }
ret = op = parse_ksym_trace_str(input_string, &ksymname, &ksym_addr); ret = op = parse_ksym_trace_str(input_string, &ksymname, &ksym_addr);
if (ret < 0) { if (ret < 0)
kfree(input_string); goto out;
return ret;
}
mutex_lock(&ksym_tracer_mutex); mutex_lock(&ksym_tracer_mutex);
...@@ -321,7 +318,7 @@ static ssize_t ksym_trace_filter_write(struct file *file, ...@@ -321,7 +318,7 @@ static ssize_t ksym_trace_filter_write(struct file *file,
if (entry->attr.bp_type != op) if (entry->attr.bp_type != op)
changed = 1; changed = 1;
else else
goto out; goto out_unlock;
break; break;
} }
} }
...@@ -336,28 +333,24 @@ static ssize_t ksym_trace_filter_write(struct file *file, ...@@ -336,28 +333,24 @@ static ssize_t ksym_trace_filter_write(struct file *file,
if (IS_ERR(entry->ksym_hbp)) if (IS_ERR(entry->ksym_hbp))
ret = PTR_ERR(entry->ksym_hbp); ret = PTR_ERR(entry->ksym_hbp);
else else
goto out; goto out_unlock;
} }
/* Error or "symbol:---" case: drop it */ /* Error or "symbol:---" case: drop it */
ksym_filter_entry_count--; ksym_filter_entry_count--;
hlist_del_rcu(&(entry->ksym_hlist)); hlist_del_rcu(&(entry->ksym_hlist));
synchronize_rcu(); synchronize_rcu();
kfree(entry); kfree(entry);
goto out; goto out_unlock;
} else { } else {
/* Check for malformed request: (4) */ /* Check for malformed request: (4) */
if (op == 0) if (op)
goto out; ret = process_new_ksym_entry(ksymname, op, ksym_addr);
ret = process_new_ksym_entry(ksymname, op, ksym_addr);
} }
out: out_unlock:
mutex_unlock(&ksym_tracer_mutex); mutex_unlock(&ksym_tracer_mutex);
out:
kfree(input_string); kfree(buf);
return !ret ? count : ret;
if (!ret)
ret = count;
return ret;
} }
static const struct file_operations ksym_tracing_fops = { static const struct file_operations ksym_tracing_fops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment