Re: [PATCH] fs/ntfs3: check wnd_set_used() in ntfs_look_free_mft()

From: Konstantin Komarov

Date: Wed Nov 11 2026 - 04:00:19 EST


On 8/5/26 09:36, Baolin Liu wrote:

From: Baolin Liu <liubaolin@xxxxxxxxxx>

wnd_set_used() can fail, but ntfs_look_free_mft() ignored
the error and could return success after leaving the MFT
bitmap unmarked.

Check the return value and unwind the new subrecord on failure.

Signed-off-by: Baolin Liu <liubaolin@xxxxxxxxxx>
---
fs/ntfs3/fsntfs.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
index d0434756029b..ab9e03156cce 100644
--- a/fs/ntfs3/fsntfs.c
+++ b/fs/ntfs3/fsntfs.c
@@ -741,10 +741,19 @@ int ntfs_look_free_mft(struct ntfs_sb_info *sbi, CLST *rno, bool mft,
}
/* We have found a record that are not reserved for next MFT. */
- if (*rno >= MFT_REC_FREE)
- wnd_set_used(wnd, *rno, 1);
- else if (*rno >= MFT_REC_RESERVED && sbi->mft.reserved_bitmap_inited)
+ if (*rno >= MFT_REC_FREE) {
+ err = wnd_set_used(wnd, *rno, 1);
+ if (err) {
+ if (ni) {
+ ni_remove_mi(ni, *mi);
+ mi_put(*mi);
+ *mi = NULL;
+ }
+ goto out;
+ }
+ } else if (*rno >= MFT_REC_RESERVED && sbi->mft.reserved_bitmap_inited) {
__set_bit(*rno - MFT_REC_RESERVED, &sbi->mft.reserved_bitmap);
+ }
out:
if (!mft)

Hello,

Sorry for the delay.
Your patch is applied, thank you.

Regards,
Konstantin