Skip to content

Commit

Permalink
ksmbd: switch to use kmemdup_nul() helper
Browse files Browse the repository at this point in the history
Use kmemdup_nul() helper instead of open-coding to
simplify the code.

Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Yang Yingliang authored and Steve French committed Aug 29, 2023
1 parent 2dde18c commit 084ba46
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions fs/smb/server/asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,10 @@ static int ksmbd_neg_token_alloc(void *context, size_t hdrlen,
{
struct ksmbd_conn *conn = context;

conn->mechToken = kmalloc(vlen + 1, GFP_KERNEL);
conn->mechToken = kmemdup_nul(value, vlen, GFP_KERNEL);
if (!conn->mechToken)
return -ENOMEM;

memcpy(conn->mechToken, value, vlen);
conn->mechToken[vlen] = '\0';
return 0;
}

Expand Down

0 comments on commit 084ba46

Please sign in to comment.