summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor O'Brien <connoro@google.com>2018-03-20 16:01:43 -0700
committerConnor O'Brien <connoro@google.com>2018-03-21 18:08:20 +0000
commit4b5b4ff4a687fd25ad6b788678a8af8014b24c66 (patch)
tree1963789f65f940a67992a0e3d835a06a08b0da25
parenteacdfbad3ba8a2602a33174452440570639405f1 (diff)
ANDROID: cpufreq: times: avoid prematurely freeing uid_entry
__krealloc may return the same pointer that's passed in if the original allocation provided enough memory to accommodate the new request. In this case the "old" uid_entry should not be freed or replaced in uid_hash_table, so add a check to avoid doing so. Bug: 74338318 Test: Hikey960 boots & shows reasonable UID numbers Change-Id: Id1a094f60a8ffcc827358d0f40c9f3ff70719cce Signed-off-by: Connor O'Brien <connoro@google.com>
-rw-r--r--drivers/cpufreq/cpufreq_times.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/cpufreq/cpufreq_times.c b/drivers/cpufreq/cpufreq_times.c
index b74017f06a8e..326a5e1acdc6 100644
--- a/drivers/cpufreq/cpufreq_times.c
+++ b/drivers/cpufreq/cpufreq_times.c
@@ -105,8 +105,10 @@ static struct uid_entry *find_or_register_uid_locked(uid_t uid)
memset(temp->time_in_state + uid_entry->max_state, 0,
(max_state - uid_entry->max_state) *
sizeof(uid_entry->time_in_state[0]));
- hlist_replace_rcu(&uid_entry->hash, &temp->hash);
- kfree_rcu(uid_entry, rcu);
+ if (temp != uid_entry) {
+ hlist_replace_rcu(&uid_entry->hash, &temp->hash);
+ kfree_rcu(uid_entry, rcu);
+ }
return temp;
}