Skip to contentSkip to conversation

firmware: qcom_scm: don't opencode kmemdup

PATCH Applied Mukesh Ojha 2 participants 2 messages Mar 10 – Mar 23

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 firmware: qcom_scm: don't opencode kmemdup

Lets not opencode kmemdup which is reported by coccinelle tool. Fix it using 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

Fixes 8b9d2050cfa0 ("firmware: qcom_scm: Add qcom_scm_pas_get_rsc_table() to get resource table")

---
changes in v2: https://lore.kernel.org/lkml/[email protected]/
- Added fixes tag.
- Removed coccinelle from the Subject.

 drivers/firmware/qcom/qcom_scm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/firmware/qcom/qcom_scm.c +1 -2
index 2fe1632f06e9..dda6b0bc1cbd 100644
@@ -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
maintainer Applied
#1 lore raw
Quoted 8 lines · Mukesh Ojha

Lets not opencode kmemdup which is reported by coccinelle tool. Fix it using 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

[...]

Applied, thanks!

[1/1] firmware: qcom_scm: don't opencode kmemdup

      commit: e32701726c0e6312aabd83aa1c00f59b0d7df276

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>