aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@tuxera.com>2010-09-30 23:43:54 -0400
committerChristoph Hellwig <hch@lst.de>2010-09-30 23:43:54 -0400
commitf17c89bfcc9cccd405098eac3ec1ebfddf03279e (patch)
treef8c33976eb35e7ee62f59fbe200a92f447d42fbd /fs
parent30d3abbec730a5a9c954a6342271f7a7db155b08 (diff)
hfsplus: fix error handling in hfsplus_symlink
We need to free the inode again on a hfsplus_create_cat failure. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/hfsplus/dir.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 7efcf75ea73a..f8ae468f4ab6 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -364,31 +364,29 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)
364static int hfsplus_symlink(struct inode *dir, struct dentry *dentry, 364static int hfsplus_symlink(struct inode *dir, struct dentry *dentry,
365 const char *symname) 365 const char *symname)
366{ 366{
367 struct super_block *sb;
368 struct inode *inode; 367 struct inode *inode;
369 int res; 368 int res;
370 369
371 sb = dir->i_sb; 370 inode = hfsplus_new_inode(dir->i_sb, S_IFLNK | S_IRWXUGO);
372 inode = hfsplus_new_inode(sb, S_IFLNK | S_IRWXUGO);
373 if (!inode) 371 if (!inode)
374 return -ENOSPC; 372 return -ENOSPC;
375 373
376 res = page_symlink(inode, symname, strlen(symname) + 1); 374 res = page_symlink(inode, symname, strlen(symname) + 1);
377 if (res) { 375 if (res)
378 inode->i_nlink = 0; 376 goto out_err;
379 hfsplus_delete_inode(inode);
380 iput(inode);
381 return res;
382 }
383 377
384 mark_inode_dirty(inode);
385 res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode); 378 res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode);
379 if (res)
380 goto out_err;
386 381
387 if (!res) { 382 hfsplus_instantiate(dentry, inode, inode->i_ino);
388 hfsplus_instantiate(dentry, inode, inode->i_ino); 383 mark_inode_dirty(inode);
389 mark_inode_dirty(inode); 384 return 0;
390 }
391 385
386out_err:
387 inode->i_nlink = 0;
388 hfsplus_delete_inode(inode);
389 iput(inode);
392 return res; 390 return res;
393} 391}
394 392