mirror of
https://github.com/torvalds/linux.git
synced 2026-09-14 08:01:12 +02:00
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>
This commit is contained in:
parent
eec908b5c0
commit
34d22551ad
|
|
@ -966,13 +966,14 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user