From: Mathieu Desnoyers Date: Wed, 27 Jul 2011 19:54:43 +0000 (-0400) Subject: LTTng kprobes support: fix empty symbol name handling X-Git-Tag: v2.0-pre3~3 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c37f2a9b96ba7b4a164901feb287f6f0de61a119;p=lttng-modules.git LTTng kprobes support: fix empty symbol name handling Signed-off-by: Mathieu Desnoyers --- diff --git a/probes/lttng-kprobes.c b/probes/lttng-kprobes.c index 38ee4513..8e1ae832 100644 --- a/probes/lttng-kprobes.c +++ b/probes/lttng-kprobes.c @@ -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;