diff options
Diffstat (limited to 'ipc/sem.c')
-rw-r--r-- | ipc/sem.c | 27 |
1 files changed, 5 insertions, 22 deletions
@@ -94,7 +94,7 @@ | |||
94 | #define sem_buildid(id, seq) ipc_buildid(id, seq) | 94 | #define sem_buildid(id, seq) ipc_buildid(id, seq) |
95 | 95 | ||
96 | static int newary(struct ipc_namespace *, struct ipc_params *); | 96 | static int newary(struct ipc_namespace *, struct ipc_params *); |
97 | static void freeary(struct ipc_namespace *, struct sem_array *); | 97 | static void freeary(struct ipc_namespace *, struct kern_ipc_perm *); |
98 | #ifdef CONFIG_PROC_FS | 98 | #ifdef CONFIG_PROC_FS |
99 | static int sysvipc_sem_proc_show(struct seq_file *s, void *it); | 99 | static int sysvipc_sem_proc_show(struct seq_file *s, void *it); |
100 | #endif | 100 | #endif |
@@ -129,25 +129,7 @@ void sem_init_ns(struct ipc_namespace *ns) | |||
129 | #ifdef CONFIG_IPC_NS | 129 | #ifdef CONFIG_IPC_NS |
130 | void sem_exit_ns(struct ipc_namespace *ns) | 130 | void sem_exit_ns(struct ipc_namespace *ns) |
131 | { | 131 | { |
132 | struct sem_array *sma; | 132 | free_ipcs(ns, &sem_ids(ns), freeary); |
133 | struct kern_ipc_perm *perm; | ||
134 | int next_id; | ||
135 | int total, in_use; | ||
136 | |||
137 | down_write(&sem_ids(ns).rw_mutex); | ||
138 | |||
139 | in_use = sem_ids(ns).in_use; | ||
140 | |||
141 | for (total = 0, next_id = 0; total < in_use; next_id++) { | ||
142 | perm = idr_find(&sem_ids(ns).ipcs_idr, next_id); | ||
143 | if (perm == NULL) | ||
144 | continue; | ||
145 | ipc_lock_by_ptr(perm); | ||
146 | sma = container_of(perm, struct sem_array, sem_perm); | ||
147 | freeary(ns, sma); | ||
148 | total++; | ||
149 | } | ||
150 | up_write(&sem_ids(ns).rw_mutex); | ||
151 | } | 133 | } |
152 | #endif | 134 | #endif |
153 | 135 | ||
@@ -542,10 +524,11 @@ static int count_semzcnt (struct sem_array * sma, ushort semnum) | |||
542 | * as a writer and the spinlock for this semaphore set hold. sem_ids.rw_mutex | 524 | * as a writer and the spinlock for this semaphore set hold. sem_ids.rw_mutex |
543 | * remains locked on exit. | 525 | * remains locked on exit. |
544 | */ | 526 | */ |
545 | static void freeary(struct ipc_namespace *ns, struct sem_array *sma) | 527 | static void freeary(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) |
546 | { | 528 | { |
547 | struct sem_undo *un; | 529 | struct sem_undo *un; |
548 | struct sem_queue *q; | 530 | struct sem_queue *q; |
531 | struct sem_array *sma = container_of(ipcp, struct sem_array, sem_perm); | ||
549 | 532 | ||
550 | /* Invalidate the existing undo structures for this semaphore set. | 533 | /* Invalidate the existing undo structures for this semaphore set. |
551 | * (They will be freed without any further action in exit_sem() | 534 | * (They will be freed without any further action in exit_sem() |
@@ -926,7 +909,7 @@ static int semctl_down(struct ipc_namespace *ns, int semid, int semnum, | |||
926 | 909 | ||
927 | switch(cmd){ | 910 | switch(cmd){ |
928 | case IPC_RMID: | 911 | case IPC_RMID: |
929 | freeary(ns, sma); | 912 | freeary(ns, ipcp); |
930 | err = 0; | 913 | err = 0; |
931 | break; | 914 | break; |
932 | case IPC_SET: | 915 | case IPC_SET: |