/* msg_ids.rw_mutex (writer) and the spinlock for this message queue are held before freeque() is called. msg_ids.rw_mutex remains locked on exit.  */
static void freeque(struct ipc_namespace *, struct kern_ipc_perm *)
/* msg_ids.rw_mutex (writer) and the spinlock for this message queue are held before freeque() is called. msg_ids.rw_mutex remains locked on exit.  */
static void freeque(struct ipc_namespace *, struct kern_ipc_perm *)
{
	struct list_head *tmp;
	struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm);
	expunge_all(msq, -EIDRM);
	ss_wakeup(&msq->q_senders, 1);
	msg_rmid(ns, msq);
	msg_unlock(msq);
	tmp = msq->q_messages.next;
	while (tmp != &msq->q_messages) {
		struct msg_msg *msg = list_entry(tmp, struct msg_msg, m_list);
		tmp = tmp->next;
		atomic_dec(&ns->msg_hdrs);
		free_msg(msg);
	}
	atomic_sub(msq->q_cbytes, &ns->msg_bytes);
	security_msg_queue_free(msq);
	ipc_rcu_putref(msq);
}