From: Jérémie Galarneau Date: Tue, 18 Feb 2020 01:13:49 +0000 (-0500) Subject: Fix: directory-handle: use of free'd handle on fstat() error X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=b2081a0f39bce45b3d1cf063308a9b77712f1a9f Fix: directory-handle: use of free'd handle on fstat() error On an error to fstat a directory handle, a directory handle is released and is still initialized as if the error had not occurred. Return NULL early from lttng_directory_handle_create_from_dirfd() to prevent those erroneous accesses. Signed-off-by: Jérémie Galarneau Change-Id: Ia2a3bb1cfe8c90d3f7f87a68286a9b8524694d3c --- diff --git a/src/common/compat/directory-handle.c b/src/common/compat/directory-handle.c index 9d2fed463..a790c5b79 100644 --- a/src/common/compat/directory-handle.c +++ b/src/common/compat/directory-handle.c @@ -164,6 +164,8 @@ struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd( if (ret) { PERROR("Failed to fstat directory file descriptor %i", dirfd); lttng_directory_handle_release(&handle->ref); + handle = NULL; + goto end; } } else { handle->directory_inode = RESERVED_AT_FDCWD_INO;