probe_event_enable/disable() check tu->consumer != NULL to avoid
the wrong uprobe_register/unregister().

We are going to kill uprobe_trace_consumer, so we add the explicit
trace_uprobe->enabled member which can be used instead.

This is the temporary change to simplify the next patch, the new
member will go away after cleanups.

Signed-off-by: Oleg Nesterov <o...@redhat.com>
---
 kernel/trace/trace_uprobe.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index f49ccf9..c430d01 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -46,6 +46,7 @@ struct trace_uprobe {
        struct list_head                list;
        struct ftrace_event_class       class;
        struct ftrace_event_call        call;
+       bool                            enabled;
        struct uprobe_trace_consumer    *consumer;
        struct trace_uprobe_filter      filter;
        struct inode                    *inode;
@@ -647,7 +648,7 @@ static int probe_event_enable(struct trace_uprobe *tu, int 
flag)
        struct uprobe_trace_consumer *utc;
        int ret = 0;
 
-       if (tu->consumer)
+       if (tu->enabled)
                return -EINTR;
 
        utc = kzalloc(sizeof(struct uprobe_trace_consumer), GFP_KERNEL);
@@ -665,6 +666,8 @@ static int probe_event_enable(struct trace_uprobe *tu, int 
flag)
                tu->consumer = NULL;
                tu->flags &= ~flag;
                kfree(utc);
+       } else {
+               tu->enabled = true;
        }
 
        return ret;
@@ -672,11 +675,12 @@ static int probe_event_enable(struct trace_uprobe *tu, 
int flag)
 
 static void probe_event_disable(struct trace_uprobe *tu, int flag)
 {
-       if (!tu->consumer)
+       if (!tu->enabled)
                return;
 
        uprobe_unregister(tu->inode, tu->offset, &tu->consumer->cons);
        tu->flags &= ~flag;
+       tu->enabled = false;
        kfree(tu->consumer);
        tu->consumer = NULL;
 }
-- 
1.5.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to