firmware: qcom_scm: Fix coccinelle warning
Subsystems (2)
PATCH 1/1 firmware: qcom_scm: Fix coccinelle warning
Fix coccinelle warning of allocation and memory copying to allocated memory by replacing with kmemdup.
cocci warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
drivers/firmware/qcom/qcom_scm.c:916:11-18: WARNING opportunity for kmemdup
---
Exact patch where this warning introduced is in Linux-next but not yet hit stable.
drivers/firmware/qcom/qcom_scm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/firmware/qcom/qcom_scm.c +1 -2
@@ -923,14 +923,13 @@ struct resource_table *qcom_scm_pas_get_rsc_table(struct qcom_scm_pas_context *c goto free_input_rt; } - tbl_ptr =kzalloc (size,GFP_KERNEL ); + tbl_ptr =kmemdup (output_rt_tzm, size,GFP_KERNEL );if (!tbl_ptr) {qcom_tzmem_free (output_rt_tzm); ret = -ENOMEM ; goto free_input_rt; } -memcpy (tbl_ptr, output_rt_tzm, size); *output_rt_size = size;qcom_tzmem_free (output_rt_tzm);
Signature · 1 line
2.50.1
Quoted 10 lines · Mukesh Ojha
Fix coccinelle warning of allocation and memory copying to allocated memory by replacing with kmemdup.
cocci warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
drivers/firmware/qcom/qcom_scm.c:916:11-18: WARNING opportunity for kmemdup
Reported-by kernel test robot <[email protected]>Signed-off-by Mukesh Ojha <[email protected]>---
Preferably the subject would say something like 'don't opencode kmemdup', but that's minor
Konrad
Quoted 7 lines · Konrad Dybcio
Quoted 6 lines · Mukesh Ojha
Fix coccinelle warning of allocation and memory copying to allocated memory by replacing with kmemdup.
cocci warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
drivers/firmware/qcom/qcom_scm.c:916:11-18: WARNING opportunity for kmemdup
Quoted 7 lines
Quoted 4 lines
Reported-by kernel test robot <[email protected]>Signed-off-by Mukesh Ojha <[email protected]>---
Preferably the subject would say something like 'don't opencode kmemdup', but that's minor
Thanks, Just checking if the tool name like coccinelle, smatch, sparse who may find some issue is not preferrable to get mentioned in commit at all ?
Quoted 4 lines
Reviewed-by Konrad Dybcio <[email protected]>Konrad
Signature · 1 line
-Mukesh Ojha
Quoted 13 lines · Mukesh Ojha
Quoted 12 lines · Konrad Dybcio
Quoted 10 lines · Mukesh Ojha
Fix coccinelle warning of allocation and memory copying to allocated memory by replacing with kmemdup.
cocci warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
drivers/firmware/qcom/qcom_scm.c:916:11-18: WARNING opportunity for kmemdup
Reported-by kernel test robot <[email protected]>Signed-off-by Mukesh Ojha <[email protected]>---
Quoted 5 lines
Quoted 2 lines
Preferably the subject would say something like 'don't opencode kmemdup', but that's minor
Thanks, Just checking if the tool name like coccinelle, smatch, sparse who may find some issue is not preferrable to get mentioned in commit at all ?
I think it's even required to mention it somewhere in the message.. I can't find the actual reference, but Greg said this last week:
https://lore.kernel.org/linux-arm-msm/2026012748-unblock-vacation-70b8@gregkh/
Konrad