Skip to content

Commit 527a4de

Browse files
tobluxJaegeuk Kim
authored andcommitted
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 <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent b19ee72 commit 527a4de

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/f2fs/acl.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,8 @@ static struct posix_acl *f2fs_acl_clone(const struct posix_acl *acl,
296296
struct posix_acl *clone = NULL;
297297

298298
if (acl) {
299-
int size = sizeof(struct posix_acl) + acl->a_count *
300-
sizeof(struct posix_acl_entry);
301-
clone = kmemdup(acl, size, flags);
299+
clone = kmemdup(acl, struct_size(acl, a_entries, acl->a_count),
300+
flags);
302301
if (clone)
303302
refcount_set(&clone->a_refcount, 1);
304303
}

0 commit comments

Comments
 (0)