From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: [PATCH 6/14] hfsplus: fix error handling in hfsplus_symlink Date: Fri, 1 Oct 2010 09:26:21 +0200 Message-ID: <20101001072621.GF27055@lst.de> References: <20101001072500.GA26972@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org To: viro@zeniv.linux.org.uk, zippel@linux-m68k.org Return-path: Received: from verein.lst.de ([213.95.11.210]:40596 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751684Ab0JAH0f (ORCPT ); Fri, 1 Oct 2010 03:26:35 -0400 Content-Disposition: inline In-Reply-To: <20101001072500.GA26972@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: We need to free the inode again on a hfsplus_create_cat failure. Signed-off-by: Christoph Hellwig Index: linux-2.6/fs/hfsplus/dir.c =================================================================== --- linux-2.6.orig/fs/hfsplus/dir.c 2010-09-30 10:04:44.372782662 +0200 +++ linux-2.6/fs/hfsplus/dir.c 2010-09-30 10:10:57.316782806 +0200 @@ -364,31 +364,29 @@ static int hfsplus_rmdir(struct inode *d static int hfsplus_symlink(struct inode *dir, struct dentry *dentry, const char *symname) { - struct super_block *sb; struct inode *inode; int res; - sb = dir->i_sb; - inode = hfsplus_new_inode(sb, S_IFLNK | S_IRWXUGO); + inode = hfsplus_new_inode(dir->i_sb, S_IFLNK | S_IRWXUGO); if (!inode) return -ENOSPC; res = page_symlink(inode, symname, strlen(symname) + 1); - if (res) { - inode->i_nlink = 0; - hfsplus_delete_inode(inode); - iput(inode); - return res; - } + if (res) + goto out_err; - mark_inode_dirty(inode); res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode); + if (res) + goto out_err; - if (!res) { - hfsplus_instantiate(dentry, inode, inode->i_ino); - mark_inode_dirty(inode); - } + hfsplus_instantiate(dentry, inode, inode->i_ino); + mark_inode_dirty(inode); + return 0; +out_err: + inode->i_nlink = 0; + hfsplus_delete_inode(inode); + iput(inode); return res; }