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>
This commit is contained in:
parent
eacdfbad3b
commit
4b5b4ff4a6
1 changed files with 4 additions and 2 deletions
|
@ -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,
|
memset(temp->time_in_state + uid_entry->max_state, 0,
|
||||||
(max_state - uid_entry->max_state) *
|
(max_state - uid_entry->max_state) *
|
||||||
sizeof(uid_entry->time_in_state[0]));
|
sizeof(uid_entry->time_in_state[0]));
|
||||||
hlist_replace_rcu(&uid_entry->hash, &temp->hash);
|
if (temp != uid_entry) {
|
||||||
kfree_rcu(uid_entry, rcu);
|
hlist_replace_rcu(&uid_entry->hash, &temp->hash);
|
||||||
|
kfree_rcu(uid_entry, rcu);
|
||||||
|
}
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue