summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Blum <thorsten.blum@linux.dev>2024-10-07 13:46:37 +0200
committerJaegeuk Kim <jaegeuk@kernel.org>2024-10-14 20:04:57 +0000
commit527a4ded09b9266a5fb100e80e05b101b53053fd (patch)
tree9feedaf3f02f06b5a4dba50c1a52bbc3ea180695
parentb19ee72722087c1d441193ce3b6b3d937ae16bf2 (diff)
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 <thorsten.blum@linux.dev> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/acl.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index 8bffdeccdbc3..1fbc0607363b 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);
}