summaryrefslogtreecommitdiffstats
path: root/drivers/tee/optee
diff options
context:
space:
mode:
authorJiapeng Chong <jiapeng.chong@linux.alibaba.com>2023-06-13 03:18:53 +0200
committerJens Wiklander <jens.wiklander@linaro.org>2023-06-15 08:49:55 +0200
commit6a8b7e80105416cc7324fda295608ea2d3f98862 (patch)
treeda732939c71fc78a8c5f644333b72214733f86fc /drivers/tee/optee
parentLinux 6.4-rc2 (diff)
downloadlinux-6a8b7e80105416cc7324fda295608ea2d3f98862.tar.xz
linux-6a8b7e80105416cc7324fda295608ea2d3f98862.zip
tee: optee: Use kmemdup() to replace kmalloc + memcpy
Use kmemdup rather than duplicating its implementation. ./drivers/tee/optee/smc_abi.c:1542:12-19: WARNING opportunity for kmemdup. Reported-by: Abaci Robot <abaci@linux.alibaba.com> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5480 Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> Reviewed-by: Sumit Garg <sumit.garg@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'drivers/tee/optee')
-rw-r--r--drivers/tee/optee/smc_abi.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c
index 49702cb08f4f..54414d4def7e 100644
--- a/drivers/tee/optee/smc_abi.c
+++ b/drivers/tee/optee/smc_abi.c
@@ -1539,12 +1539,11 @@ static int optee_load_fw(struct platform_device *pdev,
* This uses the GFP_DMA flag to ensure we are allocated memory in the
* 32-bit space since TF-A cannot map memory beyond the 32-bit boundary.
*/
- data_buf = kmalloc(fw->size, GFP_KERNEL | GFP_DMA);
+ data_buf = kmemdup(fw->data, fw->size, GFP_KERNEL | GFP_DMA);
if (!data_buf) {
rc = -ENOMEM;
goto fw_err;
}
- memcpy(data_buf, fw->data, fw->size);
data_pa = virt_to_phys(data_buf);
reg_pair_from_64(&data_pa_high, &data_pa_low, data_pa);
reg_pair_from_64(&data_size_high, &data_size_low, data_size);