From: Baolin Liu <liubaolin12138@163.com>
To: almaz.alexandrovich@paragon-software.com
Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org,
liubaolin12138@gmail.com, Baolin Liu <liubaolin@kylinos.cn>
Subject: [PATCH] fs/ntfs3: check wnd_set_used() in ntfs_look_free_mft()
Date: Wed, 5 Aug 2026 15:35:37 +0800 [thread overview]
Message-ID: <20260805073537.2044570-1-liubaolin12138@163.com> (raw)
From: Baolin Liu <liubaolin@kylinos.cn>
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@kylinos.cn>
---
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)
--
2.51.0
next reply other threads:[~2026-08-05 7:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 7:35 Baolin Liu [this message]
2026-08-05 7:36 Baolin Liu
2026-11-11 8:48 ` Konstantin Komarov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260805073537.2044570-1-liubaolin12138@163.com \
--to=liubaolin12138@163.com \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liubaolin12138@gmail.com \
--cc=liubaolin@kylinos.cn \
--cc=ntfs3@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®