Replace kmalloc + memcpy with kmemdup()
Signed-off-by: Shuqi Zhang <[email protected]>
---
fs/ext4/xattr.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 042325349098..564e28a1aa94 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1895,11 +1895,10 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
unlock_buffer(bs->bh);
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;
if (s->base == NULL)
goto cleanup;
- memcpy(s->base, BHDR(bs->bh), bs->bh->b_size);
s->first = ENTRY(header(s->base)+1);
header(s->base)->h_refcount = cpu_to_le32(1);
s->here = ENTRY(s->base + offset);
--
2.31.1
On 22/05/25 11:01AM, Shuqi Zhang wrote:
> Replace kmalloc + memcpy with kmemdup()
Thanks for the patch. A straight forward conversion.
Looks good to me. Feel free to add -
Reviewed-by: Ritesh Harjani <[email protected]>
>
> Signed-off-by: Shuqi Zhang <[email protected]>
> ---
> fs/ext4/xattr.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> index 042325349098..564e28a1aa94 100644
> --- a/fs/ext4/xattr.c
> +++ b/fs/ext4/xattr.c
> @@ -1895,11 +1895,10 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
>
> unlock_buffer(bs->bh);
> 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;
> if (s->base == NULL)
> goto cleanup;
> - memcpy(s->base, BHDR(bs->bh), bs->bh->b_size);
> s->first = ENTRY(header(s->base)+1);
> header(s->base)->h_refcount = cpu_to_le32(1);
> s->here = ENTRY(s->base + offset);
> --
> 2.31.1
>
On Wed, 25 May 2022 11:01:20 +0800, Shuqi Zhang wrote:
> Replace kmalloc + memcpy with kmemdup()
>
>
Applied, thanks!
[1/1] ext4: Use kmemdup() to replace kmalloc + memcpy
commit: befabc8759af739ddee843a5113b25a17056b8eb
Best regards,
--
Theodore Ts'o <[email protected]>