ntfs: mft: use kmemdup() instead of kmalloc() and memcpy()
Subsystems (2)
PATCH 1/1 ntfs: mft: use kmemdup() instead of kmalloc() and memcpy()
From: Mohammad Shahid <[email protected]>
Use kmemdup() instead of a separate kmalloc() and memcpy() pair, simplifying the code while preserving the existing behavior.
This issue was reported by memdup.cocci.
--- fs/ntfs/mft.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ntfs/mft.c +1 -2
@@ -2420,7 +2420,7 @@ int ntfs_mft_record_alloc(struct ntfs_volume *vol, const int mode,* record. */ - (*ni)->mrec =kmalloc (vol->mft_record_size,GFP_NOFS ); + (*ni)->mrec =kmemdup (m, vol->mft_record_size,GFP_NOFS );if (!(*ni)->mrec) {folio_unlock (folio);kunmap_local (m);
@@ -2429,7 +2429,6 @@ int ntfs_mft_record_alloc(struct ntfs_volume *vol, const int mode, goto undo_mftbmp_alloc; } -memcpy ((*ni)->mrec, m, vol->mft_record_size);post_read_mst_fixup ((struct ntfs_record *)(*ni)->mrec, vol->mft_record_size);ntfs_mft_mark_dirty (folio);folio_unlock (folio);
Signature · 1 line
2.43.0
2026년 7월 4일 (토) 오후 8:11, <[email protected]>님이 작성:
Quoted 10 lines
From: Mohammad Shahid <[email protected]>
Use
kmemdup()instead of a separatekmalloc()andmemcpy()pair, simplifying the code while preserving the existing behavior.This issue was reported by
memdup.cocci.Signed-off-by Mohammad Shahid <[email protected]>
Looks good to me.
Quoted 28 lines
--- fs/ntfs/mft.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/ntfs/mft.c +1
-3@@ -2420,7 +2420,7 @@ int ntfs_mft_record_alloc(struct ntfs_volume *vol, const int mode,* record. */ - (*ni)->mrec =kmalloc (vol->mft_record_size,GFP_NOFS ); + (*ni)->mrec =kmemdup (m, vol->mft_record_size,GFP_NOFS );if (!(*ni)->mrec) {folio_unlock (folio);kunmap_local (m);@@ -2429,7 +2429,6 @@ int ntfs_mft_record_alloc(struct ntfs_volume *vol, const int mode, goto undo_mftbmp_alloc; } -memcpy ((*ni)->mrec, m, vol->mft_record_size);post_read_mst_fixup ((struct ntfs_record *)(*ni)->mrec, vol->mft_record_size);ntfs_mft_mark_dirty (folio);folio_unlock (folio); --2.43.0
Signature · 2 lines
Thanks, Hyunchul
Quoted 10 lines · On Sat, Jul 4, 2026 at 8:11 PM <[email protected]> wrote:
From: Mohammad Shahid <[email protected]>
Use
kmemdup()instead of a separatekmalloc()andmemcpy()pair, simplifying the code while preserving the existing behavior.This issue was reported by
memdup.cocci.Signed-off-by Mohammad Shahid <[email protected]>
Applied it to #ntfs-next.
Thanks!