[16/28] files: Merge shmalloc() to fle_init()

Submitted by Kirill Tkhai on June 5, 2017, 5:25 p.m.

Details

Message ID 149668354707.25229.3592539426681163324.stgit@localhost.localdomain
State Accepted
Series "Support sockets leaked to child user_ns task"
Commit d4dbb9f2508c45d1e150b9f2b74d1cf7a3045f26
Headers show

Commit Message

Kirill Tkhai June 5, 2017, 5:25 p.m.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/files.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/files.c b/criu/files.c
index 6d21b9e1f..eeb53271e 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -685,12 +685,19 @@  int rst_file_params(int fd, FownEntry *fown, int flags)
 	return 0;
 }
 
-static void fle_init(struct fdinfo_list_entry *fle, int pid, FdinfoEntry *fe)
+static struct fdinfo_list_entry *alloc_fle(int pid, FdinfoEntry *fe)
 {
+	struct fdinfo_list_entry *fle;
+
+	fle = shmalloc(sizeof(*fle));
+	if (!fle)
+		return NULL;
 	fle->pid = pid;
 	fle->fe = fe;
 	fle->received = 0;
 	fle->stage = FLE_INITIALIZED;
+
+	return fle;
 }
 
 int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info)
@@ -701,12 +708,10 @@  int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info)
 	pr_info("Collect fdinfo pid=%d fd=%d id=%#x\n",
 		pid, e->fd, e->id);
 
-	new_le = shmalloc(sizeof(*new_le));
+	new_le = alloc_fle(pid, e);
 	if (!new_le)
 		return -1;
 
-	fle_init(new_le, pid, e);
-
 	fdesc = find_file_desc(e);
 	if (fdesc == NULL) {
 		pr_err("No file for fd %d id %#x\n", e->fd, e->id);