Commit f17c89bf authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Christoph Hellwig

hfsplus: fix error handling in hfsplus_symlink

We need to free the inode again on a hfsplus_create_cat failure.
Signed-off-by: default avatarChristoph Hellwig <hch@tuxera.com>
parent 30d3abbe
...@@ -364,31 +364,29 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -364,31 +364,29 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)
static int hfsplus_symlink(struct inode *dir, struct dentry *dentry, static int hfsplus_symlink(struct inode *dir, struct dentry *dentry,
const char *symname) const char *symname)
{ {
struct super_block *sb;
struct inode *inode; struct inode *inode;
int res; int res;
sb = dir->i_sb; inode = hfsplus_new_inode(dir->i_sb, S_IFLNK | S_IRWXUGO);
inode = hfsplus_new_inode(sb, S_IFLNK | S_IRWXUGO);
if (!inode) if (!inode)
return -ENOSPC; return -ENOSPC;
res = page_symlink(inode, symname, strlen(symname) + 1); res = page_symlink(inode, symname, strlen(symname) + 1);
if (res) { if (res)
inode->i_nlink = 0; goto out_err;
hfsplus_delete_inode(inode);
iput(inode);
return res;
}
mark_inode_dirty(inode);
res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, 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);
hfsplus_instantiate(dentry, inode, inode->i_ino); mark_inode_dirty(inode);
mark_inode_dirty(inode); return 0;
}
out_err:
inode->i_nlink = 0;
hfsplus_delete_inode(inode);
iput(inode);
return res; return res;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment