aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
authorThorsten Blum <thorsten.blum@linux.dev>2026-05-04 11:31:00 +0200
committerJarkko Sakkinen <jarkko@kernel.org>2026-05-09 18:53:17 +0300
commit26cb5b4b32ff1ad708515d5228f28930822bf6fd (patch)
tree2145c8da6b30346b41d2e4a61dc421db112e1b39 /security
parent9ec4175a30eb5adb95e446af83ddf6cb3286a82a (diff)
downloadlinux-next-history-26cb5b4b32ff1ad708515d5228f28930822bf6fd.tar.gz
keys: use kmalloc_flex in user_preparse
Use kmalloc_flex() when allocating a new struct user_key_payload in user_preparse() to replace the open-coded size arithmetic and to keep the size type-safe. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://lore.kernel.org/r/20260504093058.49720-3-thorsten.blum@linux.dev Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Diffstat (limited to 'security')
-rw-r--r--security/keys/user_defined.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/security/keys/user_defined.c b/security/keys/user_defined.c
index 686d56e4cc850..6f88b507f9279 100644
--- a/security/keys/user_defined.c
+++ b/security/keys/user_defined.c
@@ -64,7 +64,7 @@ int user_preparse(struct key_preparsed_payload *prep)
if (datalen == 0 || datalen > 32767 || !prep->data)
return -EINVAL;
- upayload = kmalloc(sizeof(*upayload) + datalen, GFP_KERNEL);
+ upayload = kmalloc_flex(*upayload, data, datalen);
if (!upayload)
return -ENOMEM;