drivers/perf: hisi: add NULL check for name
authorJunhao He <hejunhao3@huawei.com>
Mon, 3 Apr 2023 08:14:23 +0000 (16:14 +0800)
committerWill Deacon <will@kernel.org>
Mon, 17 Apr 2023 12:14:10 +0000 (13:14 +0100)
commit257aedb72e731082ab514058e57b132f0b29d707
tree3325d943a4641326668f840ee29adc3578510041
parent25d8c25025a46e7621edde2eb6d5f55c6d29ee86
drivers/perf: hisi: add NULL check for name

When allocations fails that can be NULL now.

If the name provided is NULL, then the initialization process of the PMU
type and dev will be skipped in function perf_pmu_register().
Consequently, the PMU will not be able to register into the kernel.
Moreover, in the case of unregister the PMU, the function device_del()
will need to handle NULL pointers, which potentially can cause issues.

So move this allocation above the cpuhp_state_add_instance() and directly
return if it does fail.

Signed-off-by: Junhao He <hejunhao3@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20230403081423.62460-3-hejunhao3@huawei.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c