hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/fs/ubifs/dir.c
....@@ -426,6 +426,7 @@
426426 mutex_unlock(&dir_ui->ui_mutex);
427427
428428 ubifs_release_budget(c, &req);
429
+ fscrypt_free_filename(&nm);
429430
430431 return 0;
431432
....@@ -1118,7 +1119,6 @@
11181119 int err, sz_change, len = strlen(symname);
11191120 struct fscrypt_str disk_link;
11201121 struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
1121
- .new_ino_d = ALIGN(len, 8),
11221122 .dirtied_ino = 1 };
11231123 struct fscrypt_name nm;
11241124
....@@ -1134,6 +1134,7 @@
11341134 * Budget request settings: new inode, new direntry and changing parent
11351135 * directory inode.
11361136 */
1137
+ req.new_ino_d = ALIGN(disk_link.len - 1, 8);
11371138 err = ubifs_budget_space(c, &req);
11381139 if (err)
11391140 return err;
....@@ -1289,6 +1290,8 @@
12891290 if (unlink) {
12901291 ubifs_assert(c, inode_is_locked(new_inode));
12911292
1293
+ /* Budget for old inode's data when its nlink > 1. */
1294
+ req.dirtied_ino_d = ALIGN(ubifs_inode(new_inode)->data_len, 8);
12921295 err = ubifs_purge_xattrs(new_inode);
12931296 if (err)
12941297 return err;
....@@ -1531,6 +1534,10 @@
15311534 return err;
15321535 }
15331536
1537
+ err = ubifs_budget_space(c, &req);
1538
+ if (err)
1539
+ goto out;
1540
+
15341541 lock_4_inodes(old_dir, new_dir, NULL, NULL);
15351542
15361543 time = current_time(old_dir);
....@@ -1556,6 +1563,7 @@
15561563 unlock_4_inodes(old_dir, new_dir, NULL, NULL);
15571564 ubifs_release_budget(c, &req);
15581565
1566
+out:
15591567 fscrypt_free_filename(&fst_nm);
15601568 fscrypt_free_filename(&snd_nm);
15611569 return err;