fs/ntfs3: use put_indx_node() in indx_find_sort()
PATCH 1/1 fs/ntfs3: use put_indx_node() in indx_find_sort()
indx_find_sort() frees struct indx_node without nb_put(): bare kfree() on two error paths, and kfree(index)+kfree(node) on pop. Buffer heads taken by indx_read() therefore leak. Use put_indx_node(), as indx_find_raw() already does.
194491be54e1 freed n->index on pop only; bh refs and the error paths were left. Jiasheng Jiang sent the complete put_indx_node() change earlier (v2) but it was not merged.
QEMU: 300 distinct system.ntfs_security inserts; unpatched pop path holds nbufs=1 across teardown, patched does not.
Fixes 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
Signed-off-by Iván Ezequiel Rodriguez <[email protected]>
--- fs/ntfs3/index.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/ntfs3/index.c +3 -4
@@ -1297,7 +1297,7 @@ int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni, sizeof(struct NTFS_DE) + sizeof(u64)) {if (n) {fnd_pop (fnd); -kfree (n); +put_indx_node (n); }return -EINVAL ; }
@@ -1310,7 +1310,7 @@ int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni,/* Try next level. */ e =hdr_first_de (&n->index->ihdr);if (!e) { -kfree (n); +put_indx_node (n);return -EINVAL ; }
@@ -1330,8 +1330,7 @@ int indx_find_sort(struct ntfs_index *indx, struct ntfs_inode *ni,/* Pop one level. */ if (n) {fnd_pop (fnd); -kfree (n->index); -kfree (n); +put_indx_node (n); } level = fnd->level;
Signature · 1 line
2.43.0