Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae0c3751 authored by Mark Rutland's avatar Mark Rutland Committed by Russell King
Browse files

ARM: 6975/1: pmu: reject duplicate PMU registrations



Currently, the PMU reservation framework allows for multiple PMUs of
the same type to register themselves. This can lead to a bug with the
sequence:

register_pmu(pmu1);
reserve_pmu(pmu_type);
register_pmu(pmu2);
release_pmu(pmu1);

Here, pmu1 cannot be released, and pmu2 cannot be reserved.

This patch modifies register_pmu to reject registrations where a PMU is
already present, preventing this problem. PMUs which can have multiple
instances should not use the PMU reservation framework.

Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
Acked-by: default avatarJamie Iles <jamie@jamieiles.com>
Acked-by: default avatarWill Deacon <will.deacon@arm.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent f12482c9
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -34,13 +34,13 @@ static int __devinit pmu_register(struct platform_device *pdev,
		return -EINVAL;
	}

	if (pmu_devices[type])
		pr_warning("registering new PMU device type %d overwrites "
				"previous registration!\n", type);
	else
		pr_info("registered new PMU device of type %d\n",
				type);
	if (pmu_devices[type]) {
		pr_warning("rejecting duplicate registration of PMU device "
			"type %d.", type);
		return -ENOSPC;
	}

	pr_info("registered new PMU device of type %d\n", type);
	pmu_devices[type] = pdev;
	return 0;
}