diff options
Diffstat (limited to 'kernel/trace/trace_ksym.c')
-rw-r--r-- | kernel/trace/trace_ksym.c | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c index acb87d4a4ac1..faf37fa4408c 100644 --- a/kernel/trace/trace_ksym.c +++ b/kernel/trace/trace_ksym.c | |||
@@ -236,7 +236,8 @@ static ssize_t ksym_trace_filter_read(struct file *filp, char __user *ubuf, | |||
236 | mutex_lock(&ksym_tracer_mutex); | 236 | mutex_lock(&ksym_tracer_mutex); |
237 | 237 | ||
238 | hlist_for_each_entry(entry, node, &ksym_filter_head, ksym_hlist) { | 238 | hlist_for_each_entry(entry, node, &ksym_filter_head, ksym_hlist) { |
239 | ret = trace_seq_printf(s, "%pS:", (void *)entry->attr.bp_addr); | 239 | ret = trace_seq_printf(s, "%pS:", |
240 | (void *)(unsigned long)entry->attr.bp_addr); | ||
240 | if (entry->attr.bp_type == HW_BREAKPOINT_R) | 241 | if (entry->attr.bp_type == HW_BREAKPOINT_R) |
241 | ret = trace_seq_puts(s, "r--\n"); | 242 | ret = trace_seq_puts(s, "r--\n"); |
242 | else if (entry->attr.bp_type == HW_BREAKPOINT_W) | 243 | else if (entry->attr.bp_type == HW_BREAKPOINT_W) |
@@ -278,21 +279,20 @@ static ssize_t ksym_trace_filter_write(struct file *file, | |||
278 | { | 279 | { |
279 | struct trace_ksym *entry; | 280 | struct trace_ksym *entry; |
280 | struct hlist_node *node; | 281 | struct hlist_node *node; |
281 | char *input_string, *ksymname = NULL; | 282 | char *buf, *input_string, *ksymname = NULL; |
282 | unsigned long ksym_addr = 0; | 283 | unsigned long ksym_addr = 0; |
283 | int ret, op, changed = 0; | 284 | int ret, op, changed = 0; |
284 | 285 | ||
285 | input_string = kzalloc(count + 1, GFP_KERNEL); | 286 | buf = kzalloc(count + 1, GFP_KERNEL); |
286 | if (!input_string) | 287 | if (!buf) |
287 | return -ENOMEM; | 288 | return -ENOMEM; |
288 | 289 | ||
289 | if (copy_from_user(input_string, buffer, count)) { | 290 | ret = -EFAULT; |
290 | kfree(input_string); | 291 | if (copy_from_user(buf, buffer, count)) |
291 | return -EFAULT; | 292 | goto out; |
292 | } | ||
293 | input_string[count] = '\0'; | ||
294 | 293 | ||
295 | strstrip(input_string); | 294 | buf[count] = '\0'; |
295 | input_string = strstrip(buf); | ||
296 | 296 | ||
297 | /* | 297 | /* |
298 | * Clear all breakpoints if: | 298 | * Clear all breakpoints if: |
@@ -300,18 +300,16 @@ static ssize_t ksym_trace_filter_write(struct file *file, | |||
300 | * 2: echo 0 > ksym_trace_filter | 300 | * 2: echo 0 > ksym_trace_filter |
301 | * 3: echo "*:---" > ksym_trace_filter | 301 | * 3: echo "*:---" > ksym_trace_filter |
302 | */ | 302 | */ |
303 | if (!input_string[0] || !strcmp(input_string, "0") || | 303 | if (!buf[0] || !strcmp(buf, "0") || |
304 | !strcmp(input_string, "*:---")) { | 304 | !strcmp(buf, "*:---")) { |
305 | __ksym_trace_reset(); | 305 | __ksym_trace_reset(); |
306 | kfree(input_string); | 306 | ret = 0; |
307 | return count; | 307 | goto out; |
308 | } | 308 | } |
309 | 309 | ||
310 | ret = op = parse_ksym_trace_str(input_string, &ksymname, &ksym_addr); | 310 | ret = op = parse_ksym_trace_str(input_string, &ksymname, &ksym_addr); |
311 | if (ret < 0) { | 311 | if (ret < 0) |
312 | kfree(input_string); | 312 | goto out; |
313 | return ret; | ||
314 | } | ||
315 | 313 | ||
316 | mutex_lock(&ksym_tracer_mutex); | 314 | mutex_lock(&ksym_tracer_mutex); |
317 | 315 | ||
@@ -322,7 +320,7 @@ static ssize_t ksym_trace_filter_write(struct file *file, | |||
322 | if (entry->attr.bp_type != op) | 320 | if (entry->attr.bp_type != op) |
323 | changed = 1; | 321 | changed = 1; |
324 | else | 322 | else |
325 | goto out; | 323 | goto out_unlock; |
326 | break; | 324 | break; |
327 | } | 325 | } |
328 | } | 326 | } |
@@ -337,28 +335,24 @@ static ssize_t ksym_trace_filter_write(struct file *file, | |||
337 | if (IS_ERR(entry->ksym_hbp)) | 335 | if (IS_ERR(entry->ksym_hbp)) |
338 | ret = PTR_ERR(entry->ksym_hbp); | 336 | ret = PTR_ERR(entry->ksym_hbp); |
339 | else | 337 | else |
340 | goto out; | 338 | goto out_unlock; |
341 | } | 339 | } |
342 | /* Error or "symbol:---" case: drop it */ | 340 | /* Error or "symbol:---" case: drop it */ |
343 | ksym_filter_entry_count--; | 341 | ksym_filter_entry_count--; |
344 | hlist_del_rcu(&(entry->ksym_hlist)); | 342 | hlist_del_rcu(&(entry->ksym_hlist)); |
345 | synchronize_rcu(); | 343 | synchronize_rcu(); |
346 | kfree(entry); | 344 | kfree(entry); |
347 | goto out; | 345 | goto out_unlock; |
348 | } else { | 346 | } else { |
349 | /* Check for malformed request: (4) */ | 347 | /* Check for malformed request: (4) */ |
350 | if (op == 0) | 348 | if (op) |
351 | goto out; | 349 | ret = process_new_ksym_entry(ksymname, op, ksym_addr); |
352 | ret = process_new_ksym_entry(ksymname, op, ksym_addr); | ||
353 | } | 350 | } |
354 | out: | 351 | out_unlock: |
355 | mutex_unlock(&ksym_tracer_mutex); | 352 | mutex_unlock(&ksym_tracer_mutex); |
356 | 353 | out: | |
357 | kfree(input_string); | 354 | kfree(buf); |
358 | 355 | return !ret ? count : ret; | |
359 | if (!ret) | ||
360 | ret = count; | ||
361 | return ret; | ||
362 | } | 356 | } |
363 | 357 | ||
364 | static const struct file_operations ksym_tracing_fops = { | 358 | static const struct file_operations ksym_tracing_fops = { |