mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@osdl.org>
To: manfred@colorfullife.com
Cc: akpm@osdl.org, torvalds@osdl.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fix queues_count accounting in mqueue_delete_inode()
Date: Tue, 4 May 2004 17:47:13 -0700	[thread overview]
Message-ID: <20040504174713.E21045@build.pdx.osdl.net> (raw)
In-Reply-To: <20040504174214.D21045@build.pdx.osdl.net>; from chrisw@osdl.org on Tue, May 04, 2004 at 05:42:15PM -0700

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.

--- ./ipc/mqueue.c~fix_queues_count	2004-05-04 15:10:59.000000000 -0700
+++ ./ipc/mqueue.c	2004-05-04 15:16:34.000000000 -0700
@@ -215,9 +215,11 @@ static void mqueue_delete_inode(struct i
 
 	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,

  reply	other threads:[~2004-05-05  0:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-05  0:42 [PATCH] fix memleak in sys_mq_timedsend Chris Wright
2004-05-05  0:47 ` Chris Wright [this message]
2004-05-05  1:06   ` [PATCH] simplify mqueue_inode_info->messages allocation Chris Wright
2004-05-05  1:37     ` Chris Wright
2004-05-05 13:55       ` Marcelo Tosatti
2004-05-05 22:30         ` Chris Wright

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040504174713.E21045@build.pdx.osdl.net \
    --to=chrisw@osdl.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®