effaa5
From ce733f4be5791911c009c57e803f3a08d3270a0c Mon Sep 17 00:00:00 2001
effaa5
From: Adrian Reber <areber@redhat.com>
effaa5
Date: Wed, 20 May 2020 11:57:22 +0000
effaa5
Subject: [PATCH 1/3] coverity: fix RESOURCE_LEAK criu/timens.c: 67
effaa5
effaa5
 7. criu-3.14/criu/timens.c:67: leaked_storage: Variable "img" going out of scope leaks the storage it points to.
effaa5
    65|   	if (id == 0 && empty_image(img)) {
effaa5
    66|   		pr_warn("Clocks values have not been dumped\n");
effaa5
    67|-> 		return 0;
effaa5
    68|   	}
effaa5
effaa5
Signed-off-by: Adrian Reber <areber@redhat.com>
effaa5
---
effaa5
 criu/timens.c | 1 +
effaa5
 1 file changed, 1 insertion(+)
effaa5
effaa5
diff --git a/criu/timens.c b/criu/timens.c
effaa5
index 2a7e952845..f81808abf8 100644
effaa5
--- criu-3.14/criu/timens.c
effaa5
+++ criu-3.14/criu/timens.c
effaa5
@@ -64,6 +64,7 @@ int prepare_timens(int id)
effaa5
 
effaa5
 	if (id == 0 && empty_image(img)) {
effaa5
 		pr_warn("Clocks values have not been dumped\n");
effaa5
+		close_image(img);
effaa5
 		return 0;
effaa5
 	}
effaa5
 
effaa5
effaa5
From e7e4e46cfebd69efe8681395380528826df0d529 Mon Sep 17 00:00:00 2001
effaa5
From: Adrian Reber <areber@redhat.com>
effaa5
Date: Wed, 20 May 2020 12:19:36 +0000
effaa5
Subject: [PATCH 2/3] coverity: fix FORWARD_NULL in criu/proc_parse.c: 1481
effaa5
effaa5
8. criu-3.14/criu/proc_parse.c:1511: var_deref_model: Passing null pointer "f" to "fclose", which dereferences it.
effaa5
  1509|   	exit_code = 0;
effaa5
  1510|   out:
effaa5
  1511|-> 	fclose(f);
effaa5
  1512|   	return exit_code;
effaa5
  1513|   }
effaa5
effaa5
Signed-off-by: Adrian Reber <areber@redhat.com>
effaa5
---
effaa5
 criu/proc_parse.c | 2 +-
effaa5
 1 file changed, 1 insertion(+), 1 deletion(-)
effaa5
effaa5
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
effaa5
index 4a22700aa3..d1ccd9281b 100644
effaa5
--- criu-3.14/criu/proc_parse.c
effaa5
+++ criu-3.14/criu/proc_parse.c
effaa5
@@ -1480,7 +1480,7 @@ int parse_timens_offsets(struct timespec *boff, struct timespec *moff)
effaa5
 	f = fopen_proc(PROC_SELF, "timens_offsets");
effaa5
 	if (!f) {
effaa5
 		pr_perror("Unable to open /proc/self/timens_offsets");
effaa5
-		goto out;
effaa5
+		return exit_code;
effaa5
 	}
effaa5
 	while (fgets(buf, BUF_SIZE, f)) {
effaa5
 		int64_t sec, nsec;
effaa5
effaa5
From 6b44ddf4587ecbda65c15d462a94708ac2f6f602 Mon Sep 17 00:00:00 2001
effaa5
From: Adrian Reber <areber@redhat.com>
effaa5
Date: Wed, 20 May 2020 12:38:55 +0000
effaa5
Subject: [PATCH 3/3] clang: Branch condition evaluates to a garbage value
effaa5
effaa5
criu-3.14/criu/namespaces.c:692:7: warning: Branch condition evaluates to a garbage value
effaa5
effaa5
criu-3.14/criu/namespaces.c:690:3: note: 'supported' declared without an initial value
effaa5
              protobuf_c_boolean supported;
effaa5
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
effaa5
criu-3.14/criu/namespaces.c:691:8: note: Calling 'get_ns_id'
effaa5
              id = get_ns_id(pid, &time_for_children_ns_desc, &supported);
effaa5
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
effaa5
criu-3.14/criu/namespaces.c:479:9: note: Calling '__get_ns_id'
effaa5
      return __get_ns_id(pid, nd, supported, NULL);
effaa5
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
effaa5
criu-3.14/criu/namespaces.c:454:6: note: Assuming 'proc_dir' is < 0
effaa5
      if (proc_dir < 0)
effaa5
          ^~~~~~~~~~~~
effaa5
criu-3.14/criu/namespaces.c:454:2: note: Taking true branch
effaa5
      if (proc_dir < 0)
effaa5
      ^
effaa5
criu-3.14/criu/namespaces.c:455:3: note: Returning without writing to '*supported'
effaa5
              return 0;
effaa5
              ^
effaa5
criu-3.14/criu/namespaces.c:479:9: note: Returning from '__get_ns_id'
effaa5
      return __get_ns_id(pid, nd, supported, NULL);
effaa5
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
effaa5
criu-3.14/criu/namespaces.c:479:2: note: Returning without writing to '*supported'
effaa5
      return __get_ns_id(pid, nd, supported, NULL);
effaa5
      ^
effaa5
criu-3.14/criu/namespaces.c:691:8: note: Returning from 'get_ns_id'
effaa5
              id = get_ns_id(pid, &time_for_children_ns_desc, &supported);
effaa5
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
effaa5
criu-3.14/criu/namespaces.c:692:7: note: Branch condition evaluates to a garbage value
effaa5
              if (!supported || !id) {
effaa5
                  ^~~~~~~~~~
effaa5
690|   		protobuf_c_boolean supported;
effaa5
691|   		id = get_ns_id(pid, &time_for_children_ns_desc, &supported);
effaa5
692|-> 		if (!supported || !id) {
effaa5
693|   			pr_err("Can't make timens id\n");
effaa5
694|
effaa5
effaa5
Signed-off-by: Adrian Reber <areber@redhat.com>
effaa5
---
effaa5
 criu/namespaces.c | 2 +-
effaa5
 1 file changed, 1 insertion(+), 1 deletion(-)
effaa5
effaa5
diff --git a/criu/namespaces.c b/criu/namespaces.c
effaa5
index 89d97c7bce..04f242505d 100644
effaa5
--- criu-3.14/criu/namespaces.c
effaa5
+++ criu-3.14/criu/namespaces.c
effaa5
@@ -687,7 +687,7 @@ int dump_task_ns_ids(struct pstree_item *item)
effaa5
 	}
effaa5
 	if (ids->has_time_ns_id) {
effaa5
 		unsigned int id;
effaa5
-		protobuf_c_boolean supported;
effaa5
+		protobuf_c_boolean supported = false;
effaa5
 		id = get_ns_id(pid, &time_for_children_ns_desc, &supported);
effaa5
 		if (!supported || !id) {
effaa5
 			pr_err("Can't make timens id\n");