summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Shahid <mdshahid03@gmail.com>2026-07-04 20:16:54 +0530
committerNamjae Jeon <linkinjeon@kernel.org>2026-07-06 20:29:46 +0900
commitc02bbc2556708a0389a2b620fea231e5cfd37e0f (patch)
tree7f7c6e342d9457c1ca9a50845943b23b1b2ff0c4
parentc5d69260b58c3d78b2bcfa6da5997e61ce94a147 (diff)
downloadlinux-next-c02bbc2556708a0389a2b620fea231e5cfd37e0f.tar.gz
linux-next-c02bbc2556708a0389a2b620fea231e5cfd37e0f.zip
ntfs: dir: use kmemdup() instead of kmalloc() and memcpy()
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@gmail.com> Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
-rw-r--r--fs/ntfs/dir.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index 6fa9ae3377cb..2d594cbb4ebe 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -966,13 +966,14 @@ filldir:
*/
private = file->private_data;
kfree(private->key);
- private->key = kmalloc(le16_to_cpu(next->key_length), GFP_KERNEL);
+ private->key = kmemdup(&next->key.file_name,
+ le16_to_cpu(next->key_length),
+ GFP_KERNEL);
if (!private->key) {
err = -ENOMEM;
goto out;
}
- memcpy(private->key, &next->key.file_name, le16_to_cpu(next->key_length));
private->key_length = next->key_length;
break;
}