Commit 6c51dddd authored by Markus Elfring's avatar Markus Elfring Committed by Herbert Xu

crypto: ccp - Use memdup_user() rather than duplicating its implementation

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Reviewed-by: default avatarBrijesh Singh <brijesh.singh@amd.com>
Acked-by: default avatarGary R Hook <gary.hook@amd.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 0ee991be
...@@ -367,8 +367,6 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp) ...@@ -367,8 +367,6 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp)
void *psp_copy_user_blob(u64 __user uaddr, u32 len) void *psp_copy_user_blob(u64 __user uaddr, u32 len)
{ {
void *data;
if (!uaddr || !len) if (!uaddr || !len)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -376,18 +374,7 @@ void *psp_copy_user_blob(u64 __user uaddr, u32 len) ...@@ -376,18 +374,7 @@ void *psp_copy_user_blob(u64 __user uaddr, u32 len)
if (len > SEV_FW_BLOB_MAX_SIZE) if (len > SEV_FW_BLOB_MAX_SIZE)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
data = kmalloc(len, GFP_KERNEL); return memdup_user((void __user *)(uintptr_t)uaddr, len);
if (!data)
return ERR_PTR(-ENOMEM);
if (copy_from_user(data, (void __user *)(uintptr_t)uaddr, len))
goto e_free;
return data;
e_free:
kfree(data);
return ERR_PTR(-EFAULT);
} }
EXPORT_SYMBOL_GPL(psp_copy_user_blob); EXPORT_SYMBOL_GPL(psp_copy_user_blob);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment