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

Commit f0ad99f9 authored by Junjie Wu's avatar Junjie Wu
Browse files

PM / devfreq: Fix NULL pointer dereference if freq_table is empty



If max_state is 0, freq_table will be empty. Change do-while loop to
while loop to avoid dereferencing freq_table.

Change-Id: I4a24e9b8cab8073db429c74e627b7fb50076ea93
Signed-off-by: default avatarJunjie Wu <junjiew@codeaurora.org>
parent 2172a6ec
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -918,7 +918,7 @@ static ssize_t show_available_freqs(struct device *d,

	rcu_read_lock();
	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))
@@ -930,7 +930,7 @@ static ssize_t show_available_freqs(struct device *d,
		count += scnprintf(&buf[count], (PAGE_SIZE - count - 2),
				   "%lu ", freq);
		freq++;
	} while (use_opp || (!use_opp && i < max_state));
	}
	rcu_read_unlock();

	/* Truncate the trailing space */