Skip to contentSkip to conversation

perf/thunderx2: Replace devm_kasprintf() call by devm_kstrdup() in tx2_uncore_pmu_register()

PATCH New Markus Elfring 1 participant 1 message Apr 16, 2025 Arm PMU profiling and debugging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/thunderx2: Replace devm_kasprintf() call by devm_kstrdup() in tx2_uncore_pmu_register()

From: Markus Elfring <[email protected]>
Date: Wed, 16 Apr 2025 17:15:54 +0200

Use a devm_kstrdup() call instead of a devm_kasprintf() call in this function implementation because only a single string should be copied.

The source code was transformed by using the Coccinelle software.

---
 drivers/perf/thunderx2_pmu.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/perf/thunderx2_pmu.c +1 -3
index 6ed4707bd6bb..f0d7d1f9948a 100644
@@ -736,9 +736,7 @@ static int tx2_uncore_pmu_register(
 		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
 	};
 
-	tx2_pmu->pmu.name = devm_kasprintf(dev, GFP_KERNEL,
-			"%s", name);
-
+	tx2_pmu->pmu.name = devm_kstrdup(dev, name, GFP_KERNEL);
 	return perf_pmu_register(&tx2_pmu->pmu, tx2_pmu->pmu.name, -1);
 }
 
Signature · 1 line
2.49.0