mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-10 10:39:26 +00:00
perf: arm_spe: handle devm_kasprintf() failure
[ Upstream commit754a58db6a
] devm_kasprintf() may return NULL on failure of internal allocation thus the assignment to 'name' is not safe if unchecked. If NULL is passed in for name then perf_pmu_register() would not fail but rather silently jump to skip_type which is not the intent here. As perf_pmu_register() may also return -ENOMEM returning -ENOMEM in the (unlikely) failure case of devm_kasprintf() should be fine here as well. Acked-by: Mark Rutland <mark.rutland@arm.com> Fixes:d5d9696b03
("drivers/perf: Add support for ARMv8.2 Statistical Profiling Extension") Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> [will: reworded error message] Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
af6db7e751
commit
68b4512ca6
1 changed files with 5 additions and 0 deletions
|
@ -927,6 +927,11 @@ static int arm_spe_pmu_perf_init(struct arm_spe_pmu *spe_pmu)
|
|||
|
||||
idx = atomic_inc_return(&pmu_idx);
|
||||
name = devm_kasprintf(dev, GFP_KERNEL, "%s_%d", PMUNAME, idx);
|
||||
if (!name) {
|
||||
dev_err(dev, "failed to allocate name for pmu %d\n", idx);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
return perf_pmu_register(&spe_pmu->pmu, name, -1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue