Commit 527a4ded authored by Thorsten Blum's avatar Thorsten Blum Committed by Jaegeuk Kim
Browse files

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: default avatarThorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent b19ee727
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -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);
	}