Skip to contentSkip to conversation

f2fs: Use struct_size() to improve f2fs_acl_clone()

PATCH RESEND Applied Thorsten Blum 2 participants 2 messages Oct 28, 2024 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 f2fs: Use struct_size() to improve f2fs_acl_clone()

Use struct_size() to calculate the number of bytes to allocate for a cloned acl.

---
 fs/f2fs/acl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/f2fs/acl.c +2 -3
index 8bffdeccdbc3..1fbc0607363b 100644
@@ -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);
 	}
Signature · 1 line
2.47.0
#1 lore raw
This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

Quoted 8 lines · On Mon, 28 Oct 2024 12:20:58 +0100 you wrote:

Use struct_size() to calculate the number of bytes to allocate for a cloned acl.

---
 fs/f2fs/acl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Here is the summary with links:
- [f2fs-dev,RESEND] f2fs: Use struct_size() to improve f2fs_acl_clone()

    https://git.kernel.org/jaegeuk/f2fs/c/527a4ded09b9

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html