From 9604bd17bfb1f116b6d4e56ab1d95e08cde17a06 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 6 Apr 2020 12:39:17 -0400 Subject: [PATCH] Fix: relayd: unchecked allocation result of unlinked file pool MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit `pool` is not checked for NULL after its allocation. Error out if the allocation fails. In lttng_unlinked_file_pool_create: 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: I2a7717701cf3d11de557b9ecdc6609c1f6a1fd6f --- src/common/fd-tracker/inode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/fd-tracker/inode.c b/src/common/fd-tracker/inode.c index 82799aee7..f105f5bd3 100644 --- a/src/common/fd-tracker/inode.c +++ b/src/common/fd-tracker/inode.c @@ -250,6 +250,10 @@ LTTNG_HIDDEN struct lttng_unlinked_file_pool *lttng_unlinked_file_pool_create( { struct lttng_unlinked_file_pool *pool = zmalloc(sizeof(*pool)); + if (!pool) { + goto error; + } + if (!path || *path != '/') { ERR("Unlinked file pool must be created with an absolute path, path = \"%s\"", path ? path : "NULL"); -- 2.34.1