From 3f08c89d34c931a8e52895ba8f76b6f5ae86d8a5 Mon Sep 17 00:00:00 2001 From: kernel test robot Date: Mon, 14 Nov 2022 20:49:04 +0800 Subject: [PATCH] cifsd: fix memdup.cocci warnings mainline inclusion from mainline-5.15-rc1 commit 86f52978465b8f4e384880a5fd0543e9e455fb62 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I60T7G CVE: NA Reference: https://git.kernel.org/torvalds/linux/c/86f52978465b ------------------------------- fs/cifsd/smb2pdu.c:1177:27-34: WARNING opportunity for kmemdup Use kmemdup rather than duplicating its implementation Generated by: scripts/coccinelle/api/memdup.cocci Reported-by: kernel test robot Signed-off-by: kernel test robot Signed-off-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Jason Yan Signed-off-by: Zhong Jinghua --- fs/cifsd/smb2pdu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/cifsd/smb2pdu.c b/fs/cifsd/smb2pdu.c index 7549b35bb792..e6cdc3b89d85 100644 --- a/fs/cifsd/smb2pdu.c +++ b/fs/cifsd/smb2pdu.c @@ -1161,13 +1161,11 @@ static int alloc_preauth_hash(struct ksmbd_session *sess, if (sess->Preauth_HashValue) return 0; - sess->Preauth_HashValue = kmalloc(PREAUTH_HASHVALUE_SIZE, GFP_KERNEL); + sess->Preauth_HashValue = kmemdup(conn->preauth_info->Preauth_HashValue, + PREAUTH_HASHVALUE_SIZE, GFP_KERNEL); if (!sess->Preauth_HashValue) return -ENOMEM; - memcpy(sess->Preauth_HashValue, - conn->preauth_info->Preauth_HashValue, - PREAUTH_HASHVALUE_SIZE); return 0; } -- GitLab