Unverified Commit 4dc56098 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!2657 Synchronize mainline hisilicon uncore pmu driver bugfix to openEuler-OLK-5.10

Merge Pull Request from: @ci-robot 
 
PR sync from: Junhao He <hejunhao3@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/UNRRU56PVDIZKKWNZB4RCJL4VQIKUHYT/ 
Synchronize mainline hisilicon uncore pmu driver bugfix to openEuler-OLK-5.10
This patchset includes 2 minor updates for the hisi_pcie_pmu:
- fix issue that we may touch others events in some case
- modify the event->cpu only on the success pmu::event_init()
- dix use-after-free when register hisilicon ddrc pmu fails

Junhao He (1):
  perf: hisi: Fix use-after-free when register pmu fails

Yicong Yang (2):
  drivers/perf: hisi_pcie: Check the type first in pmu::event_init()
  drivers/perf: hisi_pcie: Initialize event->cpu only on success


-- 
2.33.0
 
https://gitee.com/openeuler/kernel/issues/I8BOML 
 
Link:https://gitee.com/openeuler/kernel/pulls/2657

 

Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents dac6bbe8 3932bef1
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -359,16 +359,15 @@ static int hisi_pcie_pmu_event_init(struct perf_event *event)
	struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
	struct hw_perf_event *hwc = &event->hw;

	event->cpu = pcie_pmu->on_cpu;
	/* Check the type first before going on, otherwise it's not our event */
	if (event->attr.type != event->pmu->type)
		return -ENOENT;

	if (EXT_COUNTER_IS_USED(hisi_pcie_get_event(event)))
		hwc->event_base = HISI_PCIE_EXT_CNT;
	else
		hwc->event_base = HISI_PCIE_CNT;

	if (event->attr.type != event->pmu->type)
		return -ENOENT;

	/* Sampling is not supported. */
	if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK)
		return -EOPNOTSUPP;
@@ -379,6 +378,8 @@ static int hisi_pcie_pmu_event_init(struct perf_event *event)
	if (!hisi_pcie_pmu_validate_event_group(event))
		return -EINVAL;

	event->cpu = pcie_pmu->on_cpu;

	return 0;
}

+2 −2
Original line number Diff line number Diff line
@@ -505,7 +505,7 @@ static int hisi_pa_pmu_probe(struct platform_device *pdev)
	ret = perf_pmu_register(&pa_pmu->pmu, name, -1);
	if (ret) {
		dev_err(pa_pmu->dev, "PMU register failed, ret = %d\n", ret);
		cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HISI_PA_ONLINE,
		cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HISI_PA_ONLINE,
						    &pa_pmu->node);
		return ret;
	}
+2 −2
Original line number Diff line number Diff line
@@ -450,7 +450,7 @@ static int hisi_sllc_pmu_probe(struct platform_device *pdev)
	ret = perf_pmu_register(&sllc_pmu->pmu, name, -1);
	if (ret) {
		dev_err(sllc_pmu->dev, "PMU register failed, ret = %d\n", ret);
		cpuhp_state_remove_instance(CPUHP_AP_PERF_ARM_HISI_SLLC_ONLINE,
		cpuhp_state_remove_instance_nocalls(CPUHP_AP_PERF_ARM_HISI_SLLC_ONLINE,
						    &sllc_pmu->node);
		return ret;
	}