summaryrefslogtreecommitdiff
path: root/fs/minix/namei.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-01-18 20:30:23 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2023-01-20 03:26:34 +0300
commit2d1a9d599b3ed9b9c58f64b8b71b5b9d770ceacf (patch)
tree05fbead28b1adb47e8dcc4535b6b1492bef59b97 /fs/minix/namei.c
parentb61d15d5ff67c07907c194d4354ec0c35bc657d1 (diff)
downloadlinux-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/namei.c')
-rw-r--r--fs/minix/namei.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index 7dc481418871..382ead96bf54 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -213,10 +213,11 @@ static int minix_rename(struct user_namespace *mnt_userns,
new_de = minix_find_entry(new_dentry, &new_page);
if (!new_de)
goto out_dir;
- err = 0;
- minix_set_link(new_de, new_page, old_inode);
+ err = minix_set_link(new_de, new_page, old_inode);
kunmap(new_page);
put_page(new_page);
+ if (err)
+ goto out_dir;
new_inode->i_ctime = current_time(new_inode);
if (dir_de)
drop_nlink(new_inode);
@@ -233,8 +234,9 @@ static int minix_rename(struct user_namespace *mnt_userns,
mark_inode_dirty(old_inode);
if (dir_de) {
- minix_set_link(dir_de, dir_page, new_dir);
- inode_dec_link_count(old_dir);
+ err = minix_set_link(dir_de, dir_page, new_dir);
+ if (!err)
+ inode_dec_link_count(old_dir);
}
out_dir:
if (dir_de) {