diff mbox series

[-next] smb: switch to use kmemdup_nul() helper

Message ID 20230725123147.525642-1-yangyingliang@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] smb: switch to use kmemdup_nul() helper | expand

Commit Message

Yang Yingliang July 25, 2023, 12:31 p.m. UTC
Use kmemdup_nul() helper instead of open-coding to
simplify the code.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 fs/smb/server/asn1.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Namjae Jeon July 26, 2023, 11:52 p.m. UTC | #1
2023-07-25 21:31 GMT+09:00, Yang Yingliang <yangyingliang@huawei.com>:
> Use kmemdup_nul() helper instead of open-coding to
> simplify the code.
>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>

Thanks for your patch!
diff mbox series

Patch

diff --git a/fs/smb/server/asn1.c b/fs/smb/server/asn1.c
index cc6384f79675..4a4b2b03ff33 100644
--- a/fs/smb/server/asn1.c
+++ b/fs/smb/server/asn1.c
@@ -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;
 }