Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Rosen Penev and committed by
Steve French
3df614eb 95e1d378

+2 -3
+2 -3
fs/smb/server/transport_ipc.c
··· 55 55 struct ksmbd_ipc_msg { 56 56 unsigned int type; 57 57 unsigned int sz; 58 - unsigned char payload[]; 58 + unsigned char payload[] __counted_by(sz); 59 59 }; 60 60 61 61 struct ipc_msg_table_entry { ··· 242 242 static struct ksmbd_ipc_msg *ipc_msg_alloc(size_t sz) 243 243 { 244 244 struct ksmbd_ipc_msg *msg; 245 - size_t msg_sz = sz + sizeof(struct ksmbd_ipc_msg); 246 245 247 - msg = kvzalloc(msg_sz, KSMBD_DEFAULT_GFP); 246 + msg = kvzalloc_flex(*msg, payload, sz, KSMBD_DEFAULT_GFP); 248 247 if (msg) 249 248 msg->sz = sz; 250 249 return msg;