From: Jérémie Galarneau Date: Fri, 31 Jan 2020 22:41:08 +0000 (-0500) Subject: Fix: unchecked return value of lttng_directory_handle_create() X-Git-Tag: v2.12.0-rc1~13 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d05a3d937ddc2b666b153e6adaf9610800772b68;p=lttng-tools.git Fix: unchecked return value of lttng_directory_handle_create() Although unlikely in this case (as the path was just created), the creation of a directory handle can fail and this should always be accounted-for. 1415129 Dereference null return value If the function actually returns a null value, a null pointer dereference will occur. In lttng_unlinked_file_pool_add_inode: Return value of function which returns null is dereferenced without checking (CWE-476) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau Change-Id: I914802c25b569320e08265aae251e062bccbd50e --- diff --git a/src/common/fd-tracker/inode.c b/src/common/fd-tracker/inode.c index 727f6141a..b894f8fbf 100644 --- a/src/common/fd-tracker/inode.c +++ b/src/common/fd-tracker/inode.c @@ -133,6 +133,12 @@ static int lttng_unlinked_file_pool_add_inode( } pool->unlink_directory_handle = lttng_directory_handle_create( pool->unlink_directory_path); + if (!pool->unlink_directory_handle) { + ERR("Failed to create directory handle to unlinked file pool at %s", + pool->unlink_directory_path); + ret = -1; + goto end; + } } ret = lttng_directory_handle_rename(inode->location.directory_handle,