diff options
author | Silviu-Mihai Popescu <silviupopescu1990@gmail.com> | 2013-03-11 12:22:32 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2013-05-04 23:08:19 -0400 |
commit | f7f7c1850eb98da758731ea7edfa830ebefe24cd (patch) | |
tree | 78e8199747533ec4b78e27fd739ea68ebf13a171 /fs/cifs/sess.c | |
parent | d455b72bdd23a1d7adcbdfb5c1ceabcd7beaf853 (diff) |
fs: cifs: use kmemdup instead of kmalloc + memcpy
This replaces calls to kmalloc followed by memcpy with a single call to
kmemdup. This was found via make coccicheck.
Signed-off-by: Silviu-Mihai Popescu <silviupopescu1990@gmail.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/sess.c')
-rw-r--r-- | fs/cifs/sess.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 76809f4d3428..6f83881ff30b 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
@@ -399,12 +399,12 @@ int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, | |||
399 | return -EINVAL; | 399 | return -EINVAL; |
400 | } | 400 | } |
401 | if (tilen) { | 401 | if (tilen) { |
402 | ses->auth_key.response = kmalloc(tilen, GFP_KERNEL); | 402 | ses->auth_key.response = kmemdup(bcc_ptr + tioffset, tilen, |
403 | GFP_KERNEL); | ||
403 | if (!ses->auth_key.response) { | 404 | if (!ses->auth_key.response) { |
404 | cERROR(1, "Challenge target info allocation failure"); | 405 | cERROR(1, "Challenge target info allocation failure"); |
405 | return -ENOMEM; | 406 | return -ENOMEM; |
406 | } | 407 | } |
407 | memcpy(ses->auth_key.response, bcc_ptr + tioffset, tilen); | ||
408 | ses->auth_key.len = tilen; | 408 | ses->auth_key.len = tilen; |
409 | } | 409 | } |
410 | 410 | ||
@@ -761,14 +761,14 @@ ssetup_ntlmssp_authenticate: | |||
761 | goto ssetup_exit; | 761 | goto ssetup_exit; |
762 | } | 762 | } |
763 | 763 | ||
764 | ses->auth_key.response = kmalloc(msg->sesskey_len, GFP_KERNEL); | 764 | ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len, |
765 | GFP_KERNEL); | ||
765 | if (!ses->auth_key.response) { | 766 | if (!ses->auth_key.response) { |
766 | cERROR(1, "Kerberos can't allocate (%u bytes) memory", | 767 | cERROR(1, "Kerberos can't allocate (%u bytes) memory", |
767 | msg->sesskey_len); | 768 | msg->sesskey_len); |
768 | rc = -ENOMEM; | 769 | rc = -ENOMEM; |
769 | goto ssetup_exit; | 770 | goto ssetup_exit; |
770 | } | 771 | } |
771 | memcpy(ses->auth_key.response, msg->data, msg->sesskey_len); | ||
772 | ses->auth_key.len = msg->sesskey_len; | 772 | ses->auth_key.len = msg->sesskey_len; |
773 | 773 | ||
774 | pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC; | 774 | pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC; |