Skip to content

Commit 4efd9f0

Browse files
Shuqi Zhangtytso
authored andcommitted
ext4: use kmemdup() to replace kmalloc + memcpy
Replace kmalloc + memcpy with kmemdup() Signed-off-by: Shuqi Zhang <[email protected]> Reviewed-by: Ritesh Harjani <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 9b6641d commit 4efd9f0

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fs/ext4/xattr.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,11 +1895,10 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
18951895

18961896
unlock_buffer(bs->bh);
18971897
ea_bdebug(bs->bh, "cloning");
1898-
s->base = kmalloc(bs->bh->b_size, GFP_NOFS);
1898+
s->base = kmemdup(BHDR(bs->bh), bs->bh->b_size, GFP_NOFS);
18991899
error = -ENOMEM;
19001900
if (s->base == NULL)
19011901
goto cleanup;
1902-
memcpy(s->base, BHDR(bs->bh), bs->bh->b_size);
19031902
s->first = ENTRY(header(s->base)+1);
19041903
header(s->base)->h_refcount = cpu_to_le32(1);
19051904
s->here = ENTRY(s->base + offset);

0 commit comments

Comments
 (0)