[PATCH] ntfs: mft: use kmemdup() instead of kmalloc() and memcpy()
From: mdshahid03
Date: Sat Jul 04 2026 - 07:11:33 EST
From: Mohammad Shahid <mdshahid03@xxxxxxxxx>
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.
Signed-off-by: Mohammad Shahid <mdshahid03@xxxxxxxxx>
---
fs/ntfs/mft.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index a5019e80951b..fd07d41c2741 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -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