Fix: flt.lttng-utils.debug-info: Dereference after null check
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 10 Oct 2019 15:23:55 +0000 (11:23 -0400)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 15 Oct 2019 22:43:28 +0000 (18:43 -0400)
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 <francis.deslauriers@efficios.com>
Change-Id: I1821a4f2e39096cb3dca75033ab9ce25f4b63127
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2167
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/lttng-utils/debug-info/bin-info.c

index 31c347ea7088348b32af3efed14d07b12d877f44..080472a983f4274f29677ad9e5773ea06fd9efc2 100644 (file)
@@ -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;
 }
 
 /**
This page took 0.025814 seconds and 4 git commands to generate.