Commit b3737eac authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull pmdomain fixes from Ulf Hansson:

 - Fix detach procedure for virtual devices in genpd

 - mediatek: Fix use-after-free in scpsys_get_bus_protection_legacy()

* tag 'pmdomain-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm:
  pmdomain: mediatek: fix use-after-free in scpsys_get_bus_protection_legacy()
  pmdomain: core: Fix detach procedure for virtual devices in genpd
parents 8ab992f8 ec1fcddb
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -3089,6 +3089,7 @@ static const struct bus_type genpd_bus_type = {
static void genpd_dev_pm_detach(struct device *dev, bool power_off)
{
	struct generic_pm_domain *pd;
	bool is_virt_dev;
	unsigned int i;
	int ret = 0;

@@ -3098,6 +3099,13 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)

	dev_dbg(dev, "removing from PM domain %s\n", pd->name);

	/* Check if the device was created by genpd at attach. */
	is_virt_dev = dev->bus == &genpd_bus_type;

	/* Disable runtime PM if we enabled it at attach. */
	if (is_virt_dev)
		pm_runtime_disable(dev);

	/* Drop the default performance state */
	if (dev_gpd_data(dev)->default_pstate) {
		dev_pm_genpd_set_performance_state(dev, 0);
@@ -3123,7 +3131,7 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)
	genpd_queue_power_off_work(pd);

	/* Unregister the device if it was created by genpd. */
	if (dev->bus == &genpd_bus_type)
	if (is_virt_dev)
		device_unregister(dev);
}

+7 −3
Original line number Diff line number Diff line
@@ -1015,6 +1015,7 @@ static int scpsys_get_bus_protection_legacy(struct device *dev, struct scpsys *s
	struct device_node *node, *smi_np;
	int num_regmaps = 0, i, j;
	struct regmap *regmap[3];
	int ret = 0;

	/*
	 * Legacy code retrieves a maximum of three bus protection handles:
@@ -1065,11 +1066,14 @@ static int scpsys_get_bus_protection_legacy(struct device *dev, struct scpsys *s
	if (node) {
		regmap[2] = syscon_regmap_lookup_by_phandle(node, "mediatek,infracfg-nao");
		num_regmaps++;
		of_node_put(node);
		if (IS_ERR(regmap[2]))
			return dev_err_probe(dev, PTR_ERR(regmap[2]),
		if (IS_ERR(regmap[2])) {
			ret = dev_err_probe(dev, PTR_ERR(regmap[2]),
					     "%pOF: failed to get infracfg regmap\n",
					     node);
			of_node_put(node);
			return ret;
		}
		of_node_put(node);
	} else {
		regmap[2] = NULL;
	}