Skip to content

Commit b61d15d

Browse files
Christoph HellwigAl Viro
authored andcommitted
minix: fix error handling in minix_delete_entry
If minix_prepare_chunk fails, updating c/mtime and marking the dir inode dirty is wrong, as the inode hasn't been modified. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 35bb6a0 commit b61d15d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

fs/minix/dir.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,18 +297,20 @@ int minix_delete_entry(struct minix_dir_entry *de, struct page *page)
297297

298298
lock_page(page);
299299
err = minix_prepare_chunk(page, pos, len);
300-
if (err == 0) {
301-
if (sbi->s_version == MINIX_V3)
302-
((minix3_dirent *) de)->inode = 0;
303-
else
304-
de->inode = 0;
305-
err = dir_commit_chunk(page, pos, len);
306-
} else {
300+
if (err) {
307301
unlock_page(page);
302+
return err;
308303
}
304+
if (sbi->s_version == MINIX_V3)
305+
((minix3_dirent *)de)->inode = 0;
306+
else
307+
de->inode = 0;
308+
err = dir_commit_chunk(page, pos, len);
309+
if (err)
310+
return err;
309311
inode->i_ctime = inode->i_mtime = current_time(inode);
310312
mark_inode_dirty(inode);
311-
return err;
313+
return 0;
312314
}
313315

314316
int minix_make_empty(struct inode *inode, struct inode *dir)

0 commit comments

Comments
 (0)