tee: optee: Use kmemdup() to replace kmalloc + memcpy
Subsystems (2)
PATCH v2 1/1 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 <[email protected]>
Signed-off-by Jiapeng Chong <[email protected]>
---
Changes in v2:
-Add one commit message.
drivers/tee/optee/smc_abi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tee/optee/smc_abi.c +1 -2
@@ -1541,12 +1541,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);
Signature · 1 line
2.20.1.7.g153144c
Quoted 8 lines · Jiapeng Chong
Use kmemdup rather than duplicating its implementation.
./drivers/tee/optee/smc_abi.c:1542:12-19: WARNING opportunity for kmemdup.
Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>
Quoted 7 lines
---
Changes in v2:
-Add one commit message.drivers/tee/optee/smc_abi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Reviewed-by Sumit Garg <[email protected]>
-Sumit
Quoted 21 lines
drivers/tee/optee/smc_abi.c +1
-3@@ -1541,12 +1541,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); --2.20.1.7.g153144c
Quoted 15 lines · Sumit Garg
Quoted 12 lines · Jiapeng Chong
Use kmemdup rather than duplicating its implementation.
./drivers/tee/optee/smc_abi.c:1542:12-19: WARNING opportunity for kmemdup.
Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>---
Changes in v2:
-Add one commit message.
Quoted 5 lines
Quoted 3 lines
drivers/tee/optee/smc_abi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Reviewed-by Sumit Garg <[email protected]>
I'm picking up this.
Thanks,
Jens
Quoted 24 lines
-Sumit
Quoted 21 lines
drivers/tee/optee/smc_abi.c +1
-3@@ -1541,12 +1541,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); --2.20.1.7.g153144c