From: David Goulet Date: Thu, 26 May 2011 19:12:44 +0000 (-0400) Subject: Fix segfault when stoping a kernel session that does not exist X-Git-Tag: v2.0-pre1~112 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8429162939cad95af39b6ec8edc56959975ab316;p=lttng-tools.git Fix segfault when stoping a kernel session that does not exist Signed-off-by: David Goulet --- diff --git a/liblttsessiondcomm/liblttsessiondcomm.c b/liblttsessiondcomm/liblttsessiondcomm.c index d1e388985..ff14d7879 100644 --- a/liblttsessiondcomm/liblttsessiondcomm.c +++ b/liblttsessiondcomm/liblttsessiondcomm.c @@ -60,6 +60,7 @@ static const char *lttcomm_readable_code[] = { [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_STREAM_FAIL) ] = "Kernel create stream failed", [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_DIR_FAIL) ] = "Kernel trace directory creation failed", [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_DIR_EXIST) ] = "Kernel trace directory already exist", + [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_NO_SESSION) ] = "No kernel session found", [ LTTCOMM_ERR_INDEX(KCONSUMERD_COMMAND_SOCK_READY) ] = "Kconsumerd command socket ready", [ LTTCOMM_ERR_INDEX(KCONSUMERD_SUCCESS_RECV_FD) ] = "Kconsumerd success on receiving fds", [ LTTCOMM_ERR_INDEX(KCONSUMERD_ERROR_RECV_FD) ] = "Kconsumerd error on receiving fds", diff --git a/liblttsessiondcomm/liblttsessiondcomm.h b/liblttsessiondcomm/liblttsessiondcomm.h index 46469f15d..6c46ac255 100644 --- a/liblttsessiondcomm/liblttsessiondcomm.h +++ b/liblttsessiondcomm/liblttsessiondcomm.h @@ -113,7 +113,8 @@ enum lttcomm_return_code { LTTCOMM_KERN_CONSUMER_FAIL, /* Kernel consumer start failed */ LTTCOMM_KERN_STREAM_FAIL, /* Kernel create stream failed */ LTTCOMM_KERN_DIR_FAIL, /* Kernel trace directory creation failed */ - LTTCOMM_KERN_DIR_EXIST, /* Kernel traec directory exist */ + LTTCOMM_KERN_DIR_EXIST, /* Kernel trace directory exist */ + LTTCOMM_KERN_NO_SESSION, /* No kernel session found */ KCONSUMERD_COMMAND_SOCK_READY, /* when kconsumerd command socket ready */ KCONSUMERD_SUCCESS_RECV_FD, /* success on receiving fds */ KCONSUMERD_ERROR_RECV_FD, /* error on receiving fds */ diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 9fd5c1c75..9df204939 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -892,6 +892,11 @@ static int process_client_msg(struct command_ctx *cmd_ctx) goto setup_error; } + if (cmd_ctx->session->kernel_session == NULL) { + ret = LTTCOMM_KERN_NO_SESSION; + goto error; + } + DBG("Stop kernel tracing"); ret = kernel_stop_session(cmd_ctx->session->kernel_session);