[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070710115519.GA1519@infradead.org>
Date: Tue, 10 Jul 2007 12:55:20 +0100
From: Christoph Hellwig <hch@...radead.org>
To: "YOSHIFUJI Hideaki / ?$B5HF#1QL@" <yoshfuji@...ux-ipv6.org>
Cc: gregkh@...e.de, linux-kernel@...r.kernel.org
Subject: Re: sysfs: release mutex when kmalloc() failed in sysfs_open_file().
On Tue, Jul 10, 2007 at 01:56:46PM +0900, YOSHIFUJI Hideaki / ?$B5HF#1QL@ wrote:
> @@ -283,6 +283,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
> mutex_lock(&inode->i_mutex);
> if (!(set = inode->i_private)) {
> if (!(set = inode->i_private = kmalloc(sizeof(struct sysfs_buffer_collection), GFP_KERNEL))) {
> + mutex_unlock(&inode->i_mutex);
> error = -ENOMEM;
> goto Done;
> } else {
Not related to your code, but whoever wrote this code originally deserves
a big slap in the face for writing such obsfucated code. This should be
something like:
mutex_lock(&inode->i_mutex);
set = inode->i_private;
if (!set) {
set = kmalloc(sizeof(struct sysfs_buffer_collection),
GFP_KERNEL))) {
if (!set)
mutex_unlock(&inode->i_mutex);
error = -ENOMEM;
goto Done;
}
INIT_LIST_HEAD(&set->associates);
inode->i_private = set;
}
mutex_unlock(&inode->i_mutex);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists