aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/dir.c
diff options
context:
space:
mode:
authorTaesoo Kim <tsgatesv@gmail.com>2015-03-25 04:53:37 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2015-03-25 05:08:40 -0400
commit9401a795c6478953e10226471ba5990db5000e05 (patch)
tree4f655d1cf01561bf184c16bf4e9d323ed5d7cf3a /fs/ubifs/dir.c
parent3527a86b7ae17c949307d00e1eb7087604bca1b4 (diff)
UBIFS: fix incorrect unlocking handling
When ubifs_init_security() fails, 'ui_mutex' is incorrectly unlocked and incorrectly restores 'i_size'. Fix this. Signed-off-by: Taesoo Kim <tsgatesv@gmail.com> Fixes: d7f0b70d30ff ("UBIFS: Add security.* XATTR support for the UBIFS") Reviewed-by: Ben Shelton <ben.shelton@ni.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'fs/ubifs/dir.c')
-rw-r--r--fs/ubifs/dir.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 0fa6c803992e..5b24bc42cad9 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -272,7 +272,7 @@ static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
272 272
273 err = ubifs_init_security(dir, inode, &dentry->d_name); 273 err = ubifs_init_security(dir, inode, &dentry->d_name);
274 if (err) 274 if (err)
275 goto out_cancel; 275 goto out_inode;
276 276
277 mutex_lock(&dir_ui->ui_mutex); 277 mutex_lock(&dir_ui->ui_mutex);
278 dir->i_size += sz_change; 278 dir->i_size += sz_change;
@@ -292,6 +292,7 @@ out_cancel:
292 dir->i_size -= sz_change; 292 dir->i_size -= sz_change;
293 dir_ui->ui_size = dir->i_size; 293 dir_ui->ui_size = dir->i_size;
294 mutex_unlock(&dir_ui->ui_mutex); 294 mutex_unlock(&dir_ui->ui_mutex);
295out_inode:
295 make_bad_inode(inode); 296 make_bad_inode(inode);
296 iput(inode); 297 iput(inode);
297out_budg: 298out_budg:
@@ -732,7 +733,7 @@ static int ubifs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
732 733
733 err = ubifs_init_security(dir, inode, &dentry->d_name); 734 err = ubifs_init_security(dir, inode, &dentry->d_name);
734 if (err) 735 if (err)
735 goto out_cancel; 736 goto out_inode;
736 737
737 mutex_lock(&dir_ui->ui_mutex); 738 mutex_lock(&dir_ui->ui_mutex);
738 insert_inode_hash(inode); 739 insert_inode_hash(inode);
@@ -757,6 +758,7 @@ out_cancel:
757 dir_ui->ui_size = dir->i_size; 758 dir_ui->ui_size = dir->i_size;
758 drop_nlink(dir); 759 drop_nlink(dir);
759 mutex_unlock(&dir_ui->ui_mutex); 760 mutex_unlock(&dir_ui->ui_mutex);
761out_inode:
760 make_bad_inode(inode); 762 make_bad_inode(inode);
761 iput(inode); 763 iput(inode);
762out_budg: 764out_budg:
@@ -816,7 +818,7 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry,
816 818
817 err = ubifs_init_security(dir, inode, &dentry->d_name); 819 err = ubifs_init_security(dir, inode, &dentry->d_name);
818 if (err) 820 if (err)
819 goto out_cancel; 821 goto out_inode;
820 822
821 mutex_lock(&dir_ui->ui_mutex); 823 mutex_lock(&dir_ui->ui_mutex);
822 dir->i_size += sz_change; 824 dir->i_size += sz_change;
@@ -836,6 +838,7 @@ out_cancel:
836 dir->i_size -= sz_change; 838 dir->i_size -= sz_change;
837 dir_ui->ui_size = dir->i_size; 839 dir_ui->ui_size = dir->i_size;
838 mutex_unlock(&dir_ui->ui_mutex); 840 mutex_unlock(&dir_ui->ui_mutex);
841out_inode:
839 make_bad_inode(inode); 842 make_bad_inode(inode);
840 iput(inode); 843 iput(inode);
841out_budg: 844out_budg:
@@ -896,7 +899,7 @@ static int ubifs_symlink(struct inode *dir, struct dentry *dentry,
896 899
897 err = ubifs_init_security(dir, inode, &dentry->d_name); 900 err = ubifs_init_security(dir, inode, &dentry->d_name);
898 if (err) 901 if (err)
899 goto out_cancel; 902 goto out_inode;
900 903
901 mutex_lock(&dir_ui->ui_mutex); 904 mutex_lock(&dir_ui->ui_mutex);
902 dir->i_size += sz_change; 905 dir->i_size += sz_change;