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

Commit 5698d807 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: kgsl: Correct the refcount on current process PID"

parents 1aba8c44 0dc228c2
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -916,17 +916,24 @@ static struct kgsl_process_private *kgsl_process_private_new(
	list_for_each_entry(private, &kgsl_driver.process_list, list) {
		if (private->pid == cur_pid) {
			if (!kgsl_process_private_get(private)) {
				put_pid(cur_pid);
				private = ERR_PTR(-EINVAL);
			}
			/*
			 * We need to hold only one reference to the PID for
			 * each process struct to avoid overflowing the
			 * reference counter which can lead to use-after-free.
			 */
			put_pid(cur_pid);
			return private;
		}
	}

	/* Create a new object */
	private = kzalloc(sizeof(struct kgsl_process_private), GFP_KERNEL);
	if (private == NULL)
	if (private == NULL) {
		put_pid(cur_pid);
		return ERR_PTR(-ENOMEM);
	}

	kref_init(&private->refcount);