aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/msg.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/msg.c')
-rw-r--r--ipc/msg.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/ipc/msg.c b/ipc/msg.c
index ab0c38b29533..46585a05473e 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -72,7 +72,7 @@ struct msg_sender {
72#define msg_unlock(msq) ipc_unlock(&(msq)->q_perm) 72#define msg_unlock(msq) ipc_unlock(&(msq)->q_perm)
73#define msg_buildid(id, seq) ipc_buildid(id, seq) 73#define msg_buildid(id, seq) ipc_buildid(id, seq)
74 74
75static void freeque(struct ipc_namespace *, struct msg_queue *); 75static void freeque(struct ipc_namespace *, struct kern_ipc_perm *);
76static int newque(struct ipc_namespace *, struct ipc_params *); 76static int newque(struct ipc_namespace *, struct ipc_params *);
77#ifdef CONFIG_PROC_FS 77#ifdef CONFIG_PROC_FS
78static int sysvipc_msg_proc_show(struct seq_file *s, void *it); 78static int sysvipc_msg_proc_show(struct seq_file *s, void *it);
@@ -91,26 +91,7 @@ void msg_init_ns(struct ipc_namespace *ns)
91#ifdef CONFIG_IPC_NS 91#ifdef CONFIG_IPC_NS
92void msg_exit_ns(struct ipc_namespace *ns) 92void msg_exit_ns(struct ipc_namespace *ns)
93{ 93{
94 struct msg_queue *msq; 94 free_ipcs(ns, &msg_ids(ns), freeque);
95 struct kern_ipc_perm *perm;
96 int next_id;
97 int total, in_use;
98
99 down_write(&msg_ids(ns).rw_mutex);
100
101 in_use = msg_ids(ns).in_use;
102
103 for (total = 0, next_id = 0; total < in_use; next_id++) {
104 perm = idr_find(&msg_ids(ns).ipcs_idr, next_id);
105 if (perm == NULL)
106 continue;
107 ipc_lock_by_ptr(perm);
108 msq = container_of(perm, struct msg_queue, q_perm);
109 freeque(ns, msq);
110 total++;
111 }
112
113 up_write(&msg_ids(ns).rw_mutex);
114} 95}
115#endif 96#endif
116 97
@@ -274,9 +255,10 @@ static void expunge_all(struct msg_queue *msq, int res)
274 * msg_ids.rw_mutex (writer) and the spinlock for this message queue are held 255 * msg_ids.rw_mutex (writer) and the spinlock for this message queue are held
275 * before freeque() is called. msg_ids.rw_mutex remains locked on exit. 256 * before freeque() is called. msg_ids.rw_mutex remains locked on exit.
276 */ 257 */
277static void freeque(struct ipc_namespace *ns, struct msg_queue *msq) 258static void freeque(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp)
278{ 259{
279 struct list_head *tmp; 260 struct list_head *tmp;
261 struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm);
280 262
281 expunge_all(msq, -EIDRM); 263 expunge_all(msq, -EIDRM);
282 ss_wakeup(&msq->q_senders, 1); 264 ss_wakeup(&msq->q_senders, 1);
@@ -582,7 +564,7 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf)
582 break; 564 break;
583 } 565 }
584 case IPC_RMID: 566 case IPC_RMID:
585 freeque(ns, msq); 567 freeque(ns, &msq->q_perm);
586 break; 568 break;
587 } 569 }
588 err = 0; 570 err = 0;