LTTng kprobes support: fix empty symbol name handling
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 27 Jul 2011 19:54:43 +0000 (15:54 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 27 Jul 2011 19:54:43 +0000 (15:54 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
probes/lttng-kprobes.c

index 38ee4513811691273de7454f0415ee56c6da44ce..8e1ae832cd82abb14d0413a1aee5b13cb1cd9fc8 100644 (file)
@@ -96,22 +96,28 @@ int lttng_kprobes_register(const char *name,
 {
        int ret;
 
+       /* Kprobes expects a NULL symbol name if unused */
+       if (symbol_name[0] == '\0')
+               symbol_name = NULL;
+
        ret = lttng_create_kprobe_event(name, event);
        if (ret)
                goto error;
        memset(&event->u.kprobe.kp, 0, sizeof(event->u.kprobe.kp));
        event->u.kprobe.kp.pre_handler = lttng_kprobes_handler_pre;
-       event->u.kprobe.symbol_name =
-               kzalloc(LTTNG_SYM_NAME_LEN * sizeof(char),
-                       GFP_KERNEL);
-       if (!event->u.kprobe.symbol_name) {
-               ret = -ENOMEM;
-               goto name_error;
+       if (symbol_name) {
+               event->u.kprobe.symbol_name =
+                       kzalloc(LTTNG_SYM_NAME_LEN * sizeof(char),
+                               GFP_KERNEL);
+               if (!event->u.kprobe.symbol_name) {
+                       ret = -ENOMEM;
+                       goto name_error;
+               }
+               memcpy(event->u.kprobe.symbol_name, symbol_name,
+                      LTTNG_SYM_NAME_LEN * sizeof(char));
+               event->u.kprobe.kp.symbol_name =
+                       event->u.kprobe.symbol_name;
        }
-       memcpy(event->u.kprobe.symbol_name, symbol_name,
-              LTTNG_SYM_NAME_LEN * sizeof(char));
-       event->u.kprobe.kp.symbol_name =
-               event->u.kprobe.symbol_name;
        event->u.kprobe.kp.offset = offset;
        event->u.kprobe.kp.addr = (void *) addr;
 
This page took 0.026286 seconds and 4 git commands to generate.