[CRIU] [PATCH v2] IPC: close image files after use

Kinsbursky Stanislav skinsbursky at openvz.org
Fri Feb 17 04:02:49 EST 2012



Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>

---
 ipc_ns.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ipc_ns.c b/ipc_ns.c
index 54a44b1..61bedec 100644
--- a/ipc_ns.c
+++ b/ipc_ns.c
@@ -655,7 +655,7 @@ static int prepare_ipc_sem(int pid)
 			return ret;
 		}
 	}
-	return 0;
+	return close_safe(&fd);
 }
 
 static int prepare_ipc_msg_queue_messages(int fd, const struct ipc_msg_entry *entry)
@@ -768,7 +768,7 @@ static int prepare_ipc_msg(int pid)
 			return ret;
 		}
 	}
-	return 0;
+	return close_safe(&fd);
 }
 
 static int prepare_ipc_shm_pages(int fd, const struct ipc_shm_entry *shm)
@@ -860,7 +860,7 @@ static int prepare_ipc_shm(int pid)
 			return ret;
 		}
 	}
-	return 0;
+	return close_safe(&fd);
 }
 
 static int prepare_ipc_var(int pid)
@@ -881,7 +881,12 @@ static int prepare_ipc_var(int pid)
 
 	show_var_entry(&var);
 
-	return ipc_sysctl_req(&var, CTL_WRITE);
+	ret = ipc_sysctl_req(&var, CTL_WRITE);
+	if (ret < 0) {
+		pr_err("Failed to prepare IPC namespace variables\n");
+		return -EFAULT;
+	}
+	return close_safe(&fd);
 }
 
 int prepare_ipc_ns(int pid)



More information about the CRIU mailing list