ext4: use kmemdup() to replace kmalloc + memcpy
[ Upstream commit4efd9f0d12] Replace kmalloc + memcpy with kmemdup() Signed-off-by: Shuqi Zhang <zhangshuqi3@huawei.com> Reviewed-by: Ritesh Harjani <ritesh.list@gmail.com> Link: https://lore.kernel.org/r/20220525030120.803330-1-zhangshuqi3@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Stable-dep-of:a44e84a9b7("ext4: fix deadlock due to mbcache entry corruption") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
b8b7922374
commit
4c363e2961
+1
-2
@@ -1890,11 +1890,10 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
|
|||||||
|
|
||||||
unlock_buffer(bs->bh);
|
unlock_buffer(bs->bh);
|
||||||
ea_bdebug(bs->bh, "cloning");
|
ea_bdebug(bs->bh, "cloning");
|
||||||
s->base = kmalloc(bs->bh->b_size, GFP_NOFS);
|
s->base = kmemdup(BHDR(bs->bh), bs->bh->b_size, GFP_NOFS);
|
||||||
error = -ENOMEM;
|
error = -ENOMEM;
|
||||||
if (s->base == NULL)
|
if (s->base == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
memcpy(s->base, BHDR(bs->bh), bs->bh->b_size);
|
|
||||||
s->first = ENTRY(header(s->base)+1);
|
s->first = ENTRY(header(s->base)+1);
|
||||||
header(s->base)->h_refcount = cpu_to_le32(1);
|
header(s->base)->h_refcount = cpu_to_le32(1);
|
||||||
s->here = ENTRY(s->base + offset);
|
s->here = ENTRY(s->base + offset);
|
||||||
|
|||||||
Reference in New Issue
Block a user