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

Commit 50c2f64e authored by Qiwei Liu's avatar Qiwei Liu Committed by Gerrit - the friendly Code Review server
Browse files

PM / devfreq: fix NULL pointer dereference for freq_table



Some devices freq_table is NULL, when show available_frequencies,
shouldn't access freq_table if max_state is 0.

Change-Id: I58ffaa23c1d27c0fe147c6d4f755244c3f69fbc0
Signed-off-by: default avatarQiwei Liu <qiweil@codeaurora.org>
parent 0c098091
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1200,7 +1200,7 @@ static ssize_t available_frequencies_show(struct device *d,
	unsigned long freq = 0;

	use_opp = dev_pm_opp_get_opp_count(dev) > 0;
	do {
	while (use_opp || (!use_opp && i < max_state)) {
		if (use_opp) {
			opp = dev_pm_opp_find_freq_ceil(dev, &freq);
			if (IS_ERR(opp))
@@ -1213,7 +1213,7 @@ static ssize_t available_frequencies_show(struct device *d,
		count += scnprintf(&buf[count], (PAGE_SIZE - count - 2),
				   "%lu ", freq);
		freq++;
	} while (use_opp || (!use_opp && i < max_state));
	}

	/* Truncate the trailing space */
	if (count)