[Devel] [PATCH] Initialize the sem->sem_pending list after restoring

Dan Smith danms at us.ibm.com
Wed Jun 16 09:54:40 PDT 2010


Right now, we leave (effectively) garbage in it after restart.  Not only
must this be re-initialized (since we know it was empty on checkpoint), but
it must be initialized after being copied into the final resting place.

Without this, you get lots of fun crashes in various places :)

Signed-off-by: Dan Smith <danms at us.ibm.com>
---
 ipc/checkpoint_sem.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/ipc/checkpoint_sem.c b/ipc/checkpoint_sem.c
index ab1830e..43e3cdf 100644
--- a/ipc/checkpoint_sem.c
+++ b/ipc/checkpoint_sem.c
@@ -171,7 +171,7 @@ int restore_ipc_sem(struct ckpt_ctx *ctx, struct ipc_namespace *ns)
 	struct sem_array *sem;
 	struct sem *sma = NULL;
 	struct ipc_ids *sem_ids = &ns->ids[IPC_SEM_IDS];
-	int semflag, ret;
+	int semflag, ret, i;
 
 	h = ckpt_read_obj_type(ctx, sizeof(*h), CKPT_HDR_IPC_SEM);
 	if (IS_ERR(h))
@@ -222,6 +222,9 @@ int restore_ipc_sem(struct ckpt_ctx *ctx, struct ipc_namespace *ns)
 	sem = container_of(ipc, struct sem_array, sem_perm);
 	memcpy(sem->sem_base, sma, sem->sem_nsems * sizeof(*sma));
 
+	for (i = 0; i < sem->sem_nsems; i++)
+		INIT_LIST_HEAD(&sem->sem_base[i].sem_pending);
+
 	/* this is safe because no unauthorized access is possible */
 	ipc_unlock(ipc);
 
-- 
1.7.0.4

_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list