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

Commit 7653f2e1 authored by Ruchi Kandoi's avatar Ruchi Kandoi
Browse files

uid_cputime: Check for the range while removing range of UIDs.

Checking if the uid_entry->uid matches the uid intended to be removed will
prevent deleting unwanted uid_entry.
Type cast the key for the hashtable to the same size, as when they were
inserted. This will make sure that we can find the uid_entry we want.

Bug: 25195548
Change-Id: I567942123cfb20e4b61ad624da19ec4cc84642c1
Signed-off: Ruchi kandoi <kandoiruchi@google.com>
parent 2ccf4f4f
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -174,16 +174,17 @@ static ssize_t uid_remove_write(struct file *file,
		kstrtol(end_uid, 10, &uid_end) != 0) {
		return -EINVAL;
	}

	mutex_lock(&uid_lock);

	for (; uid_start <= uid_end; uid_start++) {
		hash_for_each_possible_safe(hash_table, uid_entry, tmp,
							hash, uid_start) {
							hash, (uid_t)uid_start) {
			if (uid_start == uid_entry->uid) {
				hash_del(&uid_entry->hash);
				kfree(uid_entry);
			}
		}
	}

	mutex_unlock(&uid_lock);
	return count;