From: Thorsten Blum Date: Mon, 7 Oct 2024 11:46:37 +0000 (+0200) Subject: f2fs: Use struct_size() to improve f2fs_acl_clone() X-Git-Tag: v6.13-rc1~77^2~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=527a4ded09b9266a5fb100e80e05b101b53053fd;p=thirdparty%2Flinux.git f2fs: Use struct_size() to improve f2fs_acl_clone() Use struct_size() to calculate the number of bytes to allocate for a cloned acl. Signed-off-by: Thorsten Blum Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim --- diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c index 8bffdeccdbc3c..1fbc0607363bd 100644 --- a/fs/f2fs/acl.c +++ b/fs/f2fs/acl.c @@ -296,9 +296,8 @@ static struct posix_acl *f2fs_acl_clone(const struct posix_acl *acl, struct posix_acl *clone = NULL; if (acl) { - int size = sizeof(struct posix_acl) + acl->a_count * - sizeof(struct posix_acl_entry); - clone = kmemdup(acl, size, flags); + clone = kmemdup(acl, struct_size(acl, a_entries, acl->a_count), + flags); if (clone) refcount_set(&clone->a_refcount, 1); }