Blob Blame History Raw
From ce733f4be5791911c009c57e803f3a08d3270a0c Mon Sep 17 00:00:00 2001
From: Adrian Reber <areber@redhat.com>
Date: Wed, 20 May 2020 11:57:22 +0000
Subject: [PATCH 1/3] coverity: fix RESOURCE_LEAK criu/timens.c: 67

 7. criu-3.14/criu/timens.c:67: leaked_storage: Variable "img" going out of scope leaks the storage it points to.
    65|   	if (id == 0 && empty_image(img)) {
    66|   		pr_warn("Clocks values have not been dumped\n");
    67|-> 		return 0;
    68|   	}

Signed-off-by: Adrian Reber <areber@redhat.com>
---
 criu/timens.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/criu/timens.c b/criu/timens.c
index 2a7e952845..f81808abf8 100644
--- criu-3.14/criu/timens.c
+++ criu-3.14/criu/timens.c
@@ -64,6 +64,7 @@ int prepare_timens(int id)
 
 	if (id == 0 && empty_image(img)) {
 		pr_warn("Clocks values have not been dumped\n");
+		close_image(img);
 		return 0;
 	}
 

From e7e4e46cfebd69efe8681395380528826df0d529 Mon Sep 17 00:00:00 2001
From: Adrian Reber <areber@redhat.com>
Date: Wed, 20 May 2020 12:19:36 +0000
Subject: [PATCH 2/3] coverity: fix FORWARD_NULL in criu/proc_parse.c: 1481

8. criu-3.14/criu/proc_parse.c:1511: var_deref_model: Passing null pointer "f" to "fclose", which dereferences it.
  1509|   	exit_code = 0;
  1510|   out:
  1511|-> 	fclose(f);
  1512|   	return exit_code;
  1513|   }

Signed-off-by: Adrian Reber <areber@redhat.com>
---
 criu/proc_parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index 4a22700aa3..d1ccd9281b 100644
--- criu-3.14/criu/proc_parse.c
+++ criu-3.14/criu/proc_parse.c
@@ -1480,7 +1480,7 @@ int parse_timens_offsets(struct timespec *boff, struct timespec *moff)
 	f = fopen_proc(PROC_SELF, "timens_offsets");
 	if (!f) {
 		pr_perror("Unable to open /proc/self/timens_offsets");
-		goto out;
+		return exit_code;
 	}
 	while (fgets(buf, BUF_SIZE, f)) {
 		int64_t sec, nsec;

From 6b44ddf4587ecbda65c15d462a94708ac2f6f602 Mon Sep 17 00:00:00 2001
From: Adrian Reber <areber@redhat.com>
Date: Wed, 20 May 2020 12:38:55 +0000
Subject: [PATCH 3/3] clang: Branch condition evaluates to a garbage value

criu-3.14/criu/namespaces.c:692:7: warning: Branch condition evaluates to a garbage value

criu-3.14/criu/namespaces.c:690:3: note: 'supported' declared without an initial value
              protobuf_c_boolean supported;
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu-3.14/criu/namespaces.c:691:8: note: Calling 'get_ns_id'
              id = get_ns_id(pid, &time_for_children_ns_desc, &supported);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu-3.14/criu/namespaces.c:479:9: note: Calling '__get_ns_id'
      return __get_ns_id(pid, nd, supported, NULL);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu-3.14/criu/namespaces.c:454:6: note: Assuming 'proc_dir' is < 0
      if (proc_dir < 0)
          ^~~~~~~~~~~~
criu-3.14/criu/namespaces.c:454:2: note: Taking true branch
      if (proc_dir < 0)
      ^
criu-3.14/criu/namespaces.c:455:3: note: Returning without writing to '*supported'
              return 0;
              ^
criu-3.14/criu/namespaces.c:479:9: note: Returning from '__get_ns_id'
      return __get_ns_id(pid, nd, supported, NULL);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu-3.14/criu/namespaces.c:479:2: note: Returning without writing to '*supported'
      return __get_ns_id(pid, nd, supported, NULL);
      ^
criu-3.14/criu/namespaces.c:691:8: note: Returning from 'get_ns_id'
              id = get_ns_id(pid, &time_for_children_ns_desc, &supported);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu-3.14/criu/namespaces.c:692:7: note: Branch condition evaluates to a garbage value
              if (!supported || !id) {
                  ^~~~~~~~~~
690|   		protobuf_c_boolean supported;
691|   		id = get_ns_id(pid, &time_for_children_ns_desc, &supported);
692|-> 		if (!supported || !id) {
693|   			pr_err("Can't make timens id\n");
694|

Signed-off-by: Adrian Reber <areber@redhat.com>
---
 criu/namespaces.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/criu/namespaces.c b/criu/namespaces.c
index 89d97c7bce..04f242505d 100644
--- criu-3.14/criu/namespaces.c
+++ criu-3.14/criu/namespaces.c
@@ -687,7 +687,7 @@ int dump_task_ns_ids(struct pstree_item *item)
 	}
 	if (ids->has_time_ns_id) {
 		unsigned int id;
-		protobuf_c_boolean supported;
+		protobuf_c_boolean supported = false;
 		id = get_ns_id(pid, &time_for_children_ns_desc, &supported);
 		if (!supported || !id) {
 			pr_err("Can't make timens id\n");