From e649b30ccb616ac25825d69442af9d2b6777bc7b Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Thu, 10 Oct 2019 11:23:55 -0400 Subject: [PATCH] Fix: flt.lttng-utils.debug-info: Dereference after null check Coverity report: CID 1401218 (#1 of 1): Dereference after null check (FORWARD_NULL) 4. var_deref_op: Dereferencing null pointer bin. Reported-by: Coverity (1401218) Dereference after null check Signed-off-by: Francis Deslauriers Change-Id: I1821a4f2e39096cb3dca75033ab9ce25f4b63127 Reviewed-on: https://review.lttng.org/c/babeltrace/+/2167 Reviewed-by: Simon Marchi CI-Build: Simon Marchi Tested-by: jenkins --- src/plugins/lttng-utils/debug-info/bin-info.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugins/lttng-utils/debug-info/bin-info.c b/src/plugins/lttng-utils/debug-info/bin-info.c index 31c347ea..080472a9 100644 --- a/src/plugins/lttng-utils/debug-info/bin-info.c +++ b/src/plugins/lttng-utils/debug-info/bin-info.c @@ -163,10 +163,9 @@ int bin_info_set_elf_file(struct bin_info *bin) { struct bt_fd_cache_handle *elf_handle = NULL; Elf *elf_file = NULL; + int ret; - if (!bin) { - goto error; - } + BT_ASSERT(bin); elf_handle = bt_fd_cache_get_handle(bin->fd_cache, bin->elf_path); if (!elf_handle) { @@ -189,12 +188,17 @@ int bin_info_set_elf_file(struct bin_info *bin) goto error; } - return 0; + + ret = 0; + goto end; error: bt_fd_cache_put_handle(bin->fd_cache, elf_handle); elf_end(elf_file); - return -1; + ret = -1; + +end: + return ret; } /** -- 2.34.1