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