ntfs: use kvfree when ascending an index tree
PATCH 1/1 ntfs: use kvfree when ascending an index tree
From: Dandan Wu <[email protected]>
ntfs_index_walk_down() allocates the index block with kvzalloc(), which may return vmalloc memory. When traversal ascends back to the root, ntfs_index_walk_up() passes that block to kfree(), which cannot free a vmalloc allocation.
Use kvfree(), as the index context cleanup already does, to handle both allocation types.
--- fs/ntfs/index.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs/index.c +1 -1
@@ -2274,7 +2274,7 @@ static struct index_entry *ntfs_index_walk_up(struct index_entry *ie, ictx->pindex--;if (!ictx->pindex) {/* we have reached the root */ -kfree (ictx->ib); +kvfree (ictx->ib); ictx->ib =NULL ; ictx->is_in_root = true;/* a new search context is to be allocated */
Signature · 1 line
2.25.1
Quoted 21 lines · Dandan Wu
From: Dandan Wu <[email protected]>
ntfs_index_walk_down()allocates the index block withkvzalloc(), which may return vmalloc memory. When traversal ascends back to the root,ntfs_index_walk_up()passes that block tokfree(), which cannot free a vmalloc allocation.Use
kvfree(), as the index context cleanup already does, to handle both allocation types.Fixes 0a8ac0c1fa0b ("ntfs: update directory operations")Signed-off-by Dandan Wu <[email protected]>--- fs/ntfs/index.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ntfs/index.c +0
-0
fs/ntfs/index.c static struct index_entry *ntfs_index_walk_up(struct index_entry *ie, · line 2280
Quoted 8 lines
fs/ntfs/index.c +1
-1@@ -2274,7 +2274,7 @@ static struct index_entry *ntfs_index_walk_up(struct index_entry *ie, ictx->pindex--;if (!ictx->pindex) {/* we have reached the root */ -kfree (ictx->ib); +kvfree (ictx->ib); ictx->ib =NULL ; ictx->is_in_root = true;/* a new search context is to be allocated */
Looks good to me.
Quoted 8 lines · Dandan Wu
From: Dandan Wu <[email protected]>
ntfs_index_walk_down()allocates the index block withkvzalloc(), which may return vmalloc memory. When traversal ascends back to the root,ntfs_index_walk_up()passes that block tokfree(), which cannot free a vmalloc allocation.
Quoted 5 lines
Use
kvfree(), as the index context cleanup already does, to handle both allocation types.Fixes 0a8ac0c1fa0b ("ntfs: update directory operations")Signed-off-by Dandan Wu <[email protected]>
Applied it to #ntfs-next.
Thanks!