From: David Goulet Date: Tue, 14 May 2013 16:52:32 +0000 (-0400) Subject: Fix: Uninitialized pointer read X-Git-Tag: v2.2.0-rc3~69 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3cc048812bf25b42003b40b6b868b9366faefafb;p=lttng-tools.git Fix: Uninitialized pointer read The lttng poll clean call is slightly changed to handle negative epoll fd so we don't close anything blindly creating perror() outputs for nothing. Issue 1019895 of coverity scan. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index c3f8ab3bd..efaaf4ffa 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3097,6 +3097,10 @@ static void *thread_manage_health(void *data) rcu_register_thread(); + /* We might hit an error path before this is set once. */ + memset(&events, 0, sizeof(events)); + events.epfd = -1; + /* Create unix socket */ sock = lttcomm_create_unix_sock(health_unix_sock_path); if (sock < 0) { diff --git a/src/common/compat/poll.h b/src/common/compat/poll.h index 9e889767f..e69d59b42 100644 --- a/src/common/compat/poll.h +++ b/src/common/compat/poll.h @@ -166,13 +166,18 @@ static inline void lttng_poll_clean(struct lttng_poll_event *events) { int ret; - if (events) { + if (!events) { + return; + } + + if (events->epfd >= 0) { ret = close(events->epfd); if (ret) { perror("close"); } - __lttng_poll_free((void *) events->events); } + + __lttng_poll_free((void *) events->events); } #else /* HAVE_EPOLL */