summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2026-03-06 09:35:22 +0300
committerSteve French <stfrench@microsoft.com>2026-04-13 02:07:54 +0300
commit3df614ebc976bb23d2f99734695c1b7ff126d7fc (patch)
tree0be2d6a140197f14ab58249c01bb9abc069b9aae
parent95e1d378ce30af134e6abb4db4e2891864467e39 (diff)
downloadlinux-3df614ebc976bb23d2f99734695c1b7ff126d7fc.tar.xz
ksmbd: ipc: use kzalloc_flex and __counted_by
The former is just a nice macro and the latter allows runtime analysis of the allocation and its size. Signed-off-by: Rosen Penev <rosenp@gmail.com> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r--fs/smb/server/transport_ipc.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/smb/server/transport_ipc.c b/fs/smb/server/transport_ipc.c
index 2dbabe2d8005..f7aa427a06fe 100644
--- a/fs/smb/server/transport_ipc.c
+++ b/fs/smb/server/transport_ipc.c
@@ -55,7 +55,7 @@ static bool ksmbd_ipc_validate_version(struct genl_info *m)
struct ksmbd_ipc_msg {
unsigned int type;
unsigned int sz;
- unsigned char payload[];
+ unsigned char payload[] __counted_by(sz);
};
struct ipc_msg_table_entry {
@@ -242,9 +242,8 @@ static void ipc_update_last_active(void)
static struct ksmbd_ipc_msg *ipc_msg_alloc(size_t sz)
{
struct ksmbd_ipc_msg *msg;
- size_t msg_sz = sz + sizeof(struct ksmbd_ipc_msg);
- msg = kvzalloc(msg_sz, KSMBD_DEFAULT_GFP);
+ msg = kvzalloc_flex(*msg, payload, sz, KSMBD_DEFAULT_GFP);
if (msg)
msg->sz = sz;
return msg;