drivers/perf: hisi_pcie: Check the type first in pmu::event_init()
authorYicong Yang <yangyicong@hisilicon.com>
Tue, 24 Oct 2023 09:29:53 +0000 (17:29 +0800)
committerWill Deacon <will@kernel.org>
Tue, 24 Oct 2023 11:30:44 +0000 (12:30 +0100)
commit6d7d51e88e21c0af1ca96a3617afef334bfeffcf
tree4071d013edfc71b6abacb2f4c0b7d608c0b1bfd6
parentab33c66fd8f124f7c4a35c96fcfbcd262764b0f6
drivers/perf: hisi_pcie: Check the type first in pmu::event_init()

Check whether the event type matches the PMU type firstly in
pmu::event_init() before touching the event. Otherwise we'll
change the events of others and lead to incorrect results.
Since in perf_init_event() we may call every pmu's event_init()
in a certain case, we should not modify the event if it's not
ours.

Fixes: 8404b0fbc7fb ("drivers/perf: hisi: Add driver for HiSilicon PCIe PMU")
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Link: https://lore.kernel.org/r/20231024092954.42297-2-yangyicong@huawei.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/perf/hisilicon/hisi_pcie_pmu.c