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

Commit f5decbf3 authored by Kyle Piefer's avatar Kyle Piefer
Browse files

msm: kgsl: Only call dev_pm_opp_put on a valid OPP



If dev_pm_opp_find_freq_floor or dev_pm_opp_find_freq_ceil
cannot find a frequency that meets the criteria, they
will return an error instead of a valid pointer. Calling
dev_pm_opp_put on this error will lead to a page fault.
Skip calling dev_pm_opp_put in the error case.

CRs-Fixed: 2318681
Change-Id: I89a0a4a9bf67311ae5cf0f03d394876fa068ae85
Signed-off-by: default avatarKyle Piefer <kpiefer@codeaurora.org>
parent f6f026ce
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -875,7 +875,7 @@ int kgsl_busmon_get_cur_freq(struct device *dev, unsigned long *freq)
static int opp_notify(struct notifier_block *nb,
	unsigned long type, void *in_opp)
{
	int result = -EINVAL, level, min_level, max_level;
	int level, min_level, max_level;
	struct kgsl_pwrctrl *pwr = container_of(nb, struct kgsl_pwrctrl, nb);
	struct kgsl_device *device = container_of(pwr,
			struct kgsl_device, pwrctrl);
@@ -884,20 +884,19 @@ static int opp_notify(struct notifier_block *nb,
	unsigned long min_freq = 0, max_freq = pwr->pwrlevels[0].gpu_freq;

	if (type != OPP_EVENT_ENABLE && type != OPP_EVENT_DISABLE)
		return result;
		return -EINVAL;

	opp = dev_pm_opp_find_freq_floor(dev, &max_freq);
	dev_pm_opp_put(opp);

	if (IS_ERR(opp)) {
	if (IS_ERR(opp))
		return PTR_ERR(opp);
	}

	opp = dev_pm_opp_find_freq_ceil(dev, &min_freq);
	dev_pm_opp_put(opp);

	opp = dev_pm_opp_find_freq_ceil(dev, &min_freq);
	if (IS_ERR(opp))
		min_freq = pwr->pwrlevels[pwr->min_pwrlevel].gpu_freq;
	else
		dev_pm_opp_put(opp);

	mutex_lock(&device->mutex);