summaryrefslogtreecommitdiff
path: root/ipc/mqueue.c
diff options
context:
space:
mode:
authorChris Wright <chrisw@osdl.org>2004-05-04 04:48:34 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-05-04 04:48:34 -0700
commit990e3971f2b7850a9cef2853c7f96945ba7fa5e1 (patch)
treeb4e46aa06cbfa47dbbd97c3cd26679f43bbf30f3 /ipc/mqueue.c
parentdae1a193e4543ebbaceaa2eab56bf3d025097a8d (diff)
[PATCH] fix queues_count accounting in mqueue_delete_inode()
During mqueue_get_inode(), it's possible that kmalloc() of the info->messages array will fail. This failure mode will cause the queues_count to be (incorrectly) decremented twice. This patch uses info->messages on mqueue_delete_inode() to determine whether the mqueue was every truly created, and hence proper accounting is needed on destruction.
Diffstat (limited to 'ipc/mqueue.c')
-rw-r--r--ipc/mqueue.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index d13a9f37e145..f7acbb55b873 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -215,9 +215,11 @@ static void mqueue_delete_inode(struct inode *inode)
clear_inode(inode);
- spin_lock(&mq_lock);
- queues_count--;
- spin_unlock(&mq_lock);
+ if (info->messages) {
+ spin_lock(&mq_lock);
+ queues_count--;
+ spin_unlock(&mq_lock);
+ }
}
static int mqueue_create(struct inode *dir, struct dentry *dentry,