diff options
author | Christoph Hellwig <hch@lst.de> | 2023-01-18 20:30:23 +0300 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2023-01-20 03:26:34 +0300 |
commit | 2d1a9d599b3ed9b9c58f64b8b71b5b9d770ceacf (patch) | |
tree | 05fbead28b1adb47e8dcc4535b6b1492bef59b97 /fs/minix/dir.c | |
parent | b61d15d5ff67c07907c194d4354ec0c35bc657d1 (diff) | |
download | linux-2d1a9d599b3ed9b9c58f64b8b71b5b9d770ceacf.tar.xz |
minix: fix error handling in minix_set_link
If minix_prepare_chunk fails, updating c/mtime and marking the
dir inode dirty is wrong, as the inode hasn't been modified. Also
propagate the error to the caller.
Note that this moves the dir_put_page call later, but that matches
other uses of this helper in the directory code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/minix/dir.c')
-rw-r--r-- | fs/minix/dir.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/fs/minix/dir.c b/fs/minix/dir.c index 242e179aa1fb..34c1cdb5dc7d 100644 --- a/fs/minix/dir.c +++ b/fs/minix/dir.c @@ -410,8 +410,8 @@ not_empty: } /* Releases the page */ -void minix_set_link(struct minix_dir_entry *de, struct page *page, - struct inode *inode) +int minix_set_link(struct minix_dir_entry *de, struct page *page, + struct inode *inode) { struct inode *dir = page->mapping->host; struct minix_sb_info *sbi = minix_sb(dir->i_sb); @@ -420,19 +420,21 @@ void minix_set_link(struct minix_dir_entry *de, struct page *page, int err; lock_page(page); - err = minix_prepare_chunk(page, pos, sbi->s_dirsize); - if (err == 0) { - if (sbi->s_version == MINIX_V3) - ((minix3_dirent *) de)->inode = inode->i_ino; - else - de->inode = inode->i_ino; - err = dir_commit_chunk(page, pos, sbi->s_dirsize); - } else { + if (err) { unlock_page(page); + return err; } + if (sbi->s_version == MINIX_V3) + ((minix3_dirent *)de)->inode = inode->i_ino; + else + de->inode = inode->i_ino; + err = dir_commit_chunk(page, pos, sbi->s_dirsize); + if (err) + return err; dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + return 0; } struct minix_dir_entry * minix_dotdot (struct inode *dir, struct page **p) |