]> www.infradead.org Git - users/dwmw2/linux.git/commit
perf: arm_spe: handle devm_kasprintf() failure
authorNicholas Mc Guire <hofrat@osadl.org>
Wed, 28 Nov 2018 11:24:47 +0000 (12:24 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Feb 2019 19:02:12 +0000 (20:02 +0100)
commit48d7d6f86d089b7bbd64436d06ca011c609dfd73
tree557497dac8c081b2be66ac637978399b72af377c
parent8576fc44ba2391a2aef530b669308138dab4da81
perf: arm_spe: handle devm_kasprintf() failure

[ Upstream commit 754a58db6a556e6e5f5e32f3e84e7d67b5bf9c8e ]

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: d5d9696b0380 ("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>
drivers/perf/arm_spe_pmu.c