drivers/perf: Add NULL check in tx2_uncore_pmu_register
PATCH 1/1 drivers/perf: Add NULL check in tx2_uncore_pmu_register
When devm_kasprintf() fails, it returns a NULL pointer. However, this return value is not properly checked in the function tx2_uncore_pmu_register.
A NULL check should be added after the devm_kasprintf() to prevent potential NULL pointer dereference error.
--- drivers/perf/thunderx2_pmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/perf/thunderx2_pmu.c +2 -1
@@ -738,7 +738,8 @@ static int tx2_uncore_pmu_register( tx2_pmu->pmu.name =devm_kasprintf (dev,GFP_KERNEL ,"%s" , name); - +if (!tx2_pmu->pmu.name) + return -ENOMEMreturn perf_pmu_register (&tx2_pmu->pmu, tx2_pmu->pmu.name,-1 ); }
Signature · 1 line
2.34.1
Quoted 3 lines
When
devm_kasprintf()fails, it returns a NULL pointer. However, this return value is not properly checked in the functiontx2_uncore_pmu_register.A NULL check should be added after the
devm_kasprintf()to prevent potential NULL pointer dereference error.
* Please adhere to word wrapping preferences around 75 characters per text line.
* Would you like to choose the imperative mood for an improved change description?
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.14#n94
Regards,
Markus