Merge branch 'linus' into tracing/urgent
[safe/jmp/linux-2.6] / kernel / trace / trace_ksym.c
index acb87d4..faf37fa 100644 (file)
@@ -236,7 +236,8 @@ static ssize_t ksym_trace_filter_read(struct file *filp, char __user *ubuf,
        mutex_lock(&ksym_tracer_mutex);
 
        hlist_for_each_entry(entry, node, &ksym_filter_head, ksym_hlist) {
-               ret = trace_seq_printf(s, "%pS:", (void *)entry->attr.bp_addr);
+               ret = trace_seq_printf(s, "%pS:",
+                               (void *)(unsigned long)entry->attr.bp_addr);
                if (entry->attr.bp_type == HW_BREAKPOINT_R)
                        ret = trace_seq_puts(s, "r--\n");
                else if (entry->attr.bp_type == HW_BREAKPOINT_W)
@@ -278,21 +279,20 @@ static ssize_t ksym_trace_filter_write(struct file *file,
 {
        struct trace_ksym *entry;
        struct hlist_node *node;
-       char *input_string, *ksymname = NULL;
+       char *buf, *input_string, *ksymname = NULL;
        unsigned long ksym_addr = 0;
        int ret, op, changed = 0;
 
-       input_string = kzalloc(count + 1, GFP_KERNEL);
-       if (!input_string)
+       buf = kzalloc(count + 1, GFP_KERNEL);
+       if (!buf)
                return -ENOMEM;
 
-       if (copy_from_user(input_string, buffer, count)) {
-               kfree(input_string);
-               return -EFAULT;
-       }
-       input_string[count] = '\0';
+       ret = -EFAULT;
+       if (copy_from_user(buf, buffer, count))
+               goto out;
 
-       strstrip(input_string);
+       buf[count] = '\0';
+       input_string = strstrip(buf);
 
        /*
         * Clear all breakpoints if:
@@ -300,18 +300,16 @@ static ssize_t ksym_trace_filter_write(struct file *file,
         * 2: echo 0 > ksym_trace_filter
         * 3: echo "*:---" > ksym_trace_filter
         */
-       if (!input_string[0] || !strcmp(input_string, "0") ||
-           !strcmp(input_string, "*:---")) {
+       if (!buf[0] || !strcmp(buf, "0") ||
+           !strcmp(buf, "*:---")) {
                __ksym_trace_reset();
-               kfree(input_string);
-               return count;
+               ret = 0;
+               goto out;
        }
 
        ret = op = parse_ksym_trace_str(input_string, &ksymname, &ksym_addr);
-       if (ret < 0) {
-               kfree(input_string);
-               return ret;
-       }
+       if (ret < 0)
+               goto out;
 
        mutex_lock(&ksym_tracer_mutex);
 
@@ -322,7 +320,7 @@ static ssize_t ksym_trace_filter_write(struct file *file,
                        if (entry->attr.bp_type != op)
                                changed = 1;
                        else
-                               goto out;
+                               goto out_unlock;
                        break;
                }
        }
@@ -337,28 +335,24 @@ static ssize_t ksym_trace_filter_write(struct file *file,
                        if (IS_ERR(entry->ksym_hbp))
                                ret = PTR_ERR(entry->ksym_hbp);
                        else
-                               goto out;
+                               goto out_unlock;
                }
                /* Error or "symbol:---" case: drop it */
                ksym_filter_entry_count--;
                hlist_del_rcu(&(entry->ksym_hlist));
                synchronize_rcu();
                kfree(entry);
-               goto out;
+               goto out_unlock;
        } else {
                /* Check for malformed request: (4) */
-               if (op == 0)
-                       goto out;
-               ret = process_new_ksym_entry(ksymname, op, ksym_addr);
+               if (op)
+                       ret = process_new_ksym_entry(ksymname, op, ksym_addr);
        }
-out:
+out_unlock:
        mutex_unlock(&ksym_tracer_mutex);
-
-       kfree(input_string);
-
-       if (!ret)
-               ret = count;
-       return ret;
+out:
+       kfree(buf);
+       return !ret ? count : ret;
 }
 
 static const struct file_operations ksym_tracing_fops = {