aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2009-12-10 17:46:52 -0500
committerThomas Gleixner <tglx@linutronix.de>2009-12-10 18:01:36 -0500
commitd954fbf0ff6b5fdfb32350e85a2f15d3db976506 (patch)
tree3814d5878ed43b7f3cd36bdfe08053bb3d5fc0d9 /kernel
parent788d70dce0184eccc249ac6f05aa38b385b7497c (diff)
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: Thomas Gleixner <tglx@linutronix.de> Cc: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Cc: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace_ksym.c49
1 files changed, 21 insertions, 28 deletions
diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c
index ddfa0fd43bc0..64e7a5bd6692 100644
--- a/kernel/trace/trace_ksym.c
+++ b/kernel/trace/trace_ksym.c
@@ -277,21 +277,20 @@ static ssize_t ksym_trace_filter_write(struct file *file,
277{ 277{
278 struct trace_ksym *entry; 278 struct trace_ksym *entry;
279 struct hlist_node *node; 279 struct hlist_node *node;
280 char *input_string, *ksymname = NULL; 280 char *buf, *input_string, *ksymname = NULL;
281 unsigned long ksym_addr = 0; 281 unsigned long ksym_addr = 0;
282 int ret, op, changed = 0; 282 int ret, op, changed = 0;
283 283
284 input_string = kzalloc(count + 1, GFP_KERNEL); 284 buf = kzalloc(count + 1, GFP_KERNEL);
285 if (!input_string) 285 if (!buf)
286 return -ENOMEM; 286 return -ENOMEM;
287 287
288 if (copy_from_user(input_string, buffer, count)) { 288 ret = -EFAULT;
289 kfree(input_string); 289 if (copy_from_user(buf, buffer, count))
290 return -EFAULT; 290 goto out;
291 }
292 input_string[count] = '\0';
293 291
294 strstrip(input_string); 292 buf[count] = '\0';
293 input_string = strstrip(buf);
295 294
296 /* 295 /*
297 * Clear all breakpoints if: 296 * Clear all breakpoints if:
@@ -302,15 +301,13 @@ static ssize_t ksym_trace_filter_write(struct file *file,
302 if (!input_string[0] || !strcmp(input_string, "0") || 301 if (!input_string[0] || !strcmp(input_string, "0") ||
303 !strcmp(input_string, "*:---")) { 302 !strcmp(input_string, "*:---")) {
304 __ksym_trace_reset(); 303 __ksym_trace_reset();
305 kfree(input_string); 304 ret = 0;
306 return count; 305 goto out;
307 } 306 }
308 307
309 ret = op = parse_ksym_trace_str(input_string, &ksymname, &ksym_addr); 308 ret = op = parse_ksym_trace_str(input_string, &ksymname, &ksym_addr);
310 if (ret < 0) { 309 if (ret < 0)
311 kfree(input_string); 310 goto out;
312 return ret;
313 }
314 311
315 mutex_lock(&ksym_tracer_mutex); 312 mutex_lock(&ksym_tracer_mutex);
316 313
@@ -321,7 +318,7 @@ static ssize_t ksym_trace_filter_write(struct file *file,
321 if (entry->attr.bp_type != op) 318 if (entry->attr.bp_type != op)
322 changed = 1; 319 changed = 1;
323 else 320 else
324 goto out; 321 goto out_unlock;
325 break; 322 break;
326 } 323 }
327 } 324 }
@@ -336,28 +333,24 @@ static ssize_t ksym_trace_filter_write(struct file *file,
336 if (IS_ERR(entry->ksym_hbp)) 333 if (IS_ERR(entry->ksym_hbp))
337 ret = PTR_ERR(entry->ksym_hbp); 334 ret = PTR_ERR(entry->ksym_hbp);
338 else 335 else
339 goto out; 336 goto out_unlock;
340 } 337 }
341 /* Error or "symbol:---" case: drop it */ 338 /* Error or "symbol:---" case: drop it */
342 ksym_filter_entry_count--; 339 ksym_filter_entry_count--;
343 hlist_del_rcu(&(entry->ksym_hlist)); 340 hlist_del_rcu(&(entry->ksym_hlist));
344 synchronize_rcu(); 341 synchronize_rcu();
345 kfree(entry); 342 kfree(entry);
346 goto out; 343 goto out_unlock;
347 } else { 344 } else {
348 /* Check for malformed request: (4) */ 345 /* Check for malformed request: (4) */
349 if (op == 0) 346 if (op)
350 goto out; 347 ret = process_new_ksym_entry(ksymname, op, ksym_addr);
351 ret = process_new_ksym_entry(ksymname, op, ksym_addr);
352 } 348 }
353out: 349out_unlock:
354 mutex_unlock(&ksym_tracer_mutex); 350 mutex_unlock(&ksym_tracer_mutex);
355 351out:
356 kfree(input_string); 352 kfree(buf);
357 353 return !ret ? count : ret;
358 if (!ret)
359 ret = count;
360 return ret;
361} 354}
362 355
363static const struct file_operations ksym_tracing_fops = { 356static const struct file_operations ksym_tracing_fops = {