* [PATCH] fs/ntfs3: check wnd_set_used() in ntfs_look_free_mft()
@ 2026-08-05 7:36 Baolin Liu
2026-11-11 8:48 ` Konstantin Komarov
0 siblings, 1 reply; 3+ messages in thread
From: Baolin Liu @ 2026-08-05 7:36 UTC (permalink / raw)
To: almaz.alexandrovich
Cc: ntfs3, linux-kernel, liubaolin12138, liubaolin12138, Baolin Liu
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/ntfs3: check wnd_set_used() in ntfs_look_free_mft()
2026-08-05 7:36 [PATCH] fs/ntfs3: check wnd_set_used() in ntfs_look_free_mft() Baolin Liu
@ 2026-11-11 8:48 ` Konstantin Komarov
0 siblings, 0 replies; 3+ messages in thread
From: Konstantin Komarov @ 2026-11-11 8:48 UTC (permalink / raw)
To: Baolin Liu; +Cc: ntfs3, linux-kernel, liubaolin12138, Baolin Liu
On 8/5/26 09:36, Baolin Liu wrote:
> 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)
Hello,
Sorry for the delay.
Your patch is applied, thank you.
Regards,
Konstantin
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] fs/ntfs3: check wnd_set_used() in ntfs_look_free_mft()
@ 2026-08-05 7:35 Baolin Liu
0 siblings, 0 replies; 3+ messages in thread
From: Baolin Liu @ 2026-08-05 7:35 UTC (permalink / raw)
To: almaz.alexandrovich; +Cc: ntfs3, linux-kernel, liubaolin12138, Baolin Liu
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-11 8:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-05 7:36 [PATCH] fs/ntfs3: check wnd_set_used() in ntfs_look_free_mft() Baolin Liu
2026-11-11 8:48 ` Konstantin Komarov
-- strict thread matches above, loose matches on Subject: below --
2026-08-05 7:35 Baolin Liu
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®