Skip to content

Commit 3df614e

Browse files
nehebsmfrench
authored andcommitted
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>
1 parent 95e1d37 commit 3df614e

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

fs/smb/server/transport_ipc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static bool ksmbd_ipc_validate_version(struct genl_info *m)
5555
struct ksmbd_ipc_msg {
5656
unsigned int type;
5757
unsigned int sz;
58-
unsigned char payload[];
58+
unsigned char payload[] __counted_by(sz);
5959
};
6060

6161
struct ipc_msg_table_entry {
@@ -242,9 +242,8 @@ static void ipc_update_last_active(void)
242242
static struct ksmbd_ipc_msg *ipc_msg_alloc(size_t sz)
243243
{
244244
struct ksmbd_ipc_msg *msg;
245-
size_t msg_sz = sz + sizeof(struct ksmbd_ipc_msg);
246245

247-
msg = kvzalloc(msg_sz, KSMBD_DEFAULT_GFP);
246+
msg = kvzalloc_flex(*msg, payload, sz, KSMBD_DEFAULT_GFP);
248247
if (msg)
249248
msg->sz = sz;
250249
return msg;

0 commit comments

Comments
 (0)