summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2021-03-16 08:55:48 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2021-03-16 08:55:48 -0700
commit92e77745100358bfc76baa39a3e670904fb8b52f (patch)
tree82d2efb8d768d01bc867d5b3c913f78ab7bb35ec
parent9ca218394ed4dd04d5da32ba12e8cecdcc5e1e03 (diff)
parent8b5ba278ed4b370ce85cda5f997d1027db168ac1 (diff)
Merge "msm: kgsl: Correct the refcount on current process PID."
-rw-r--r--drivers/gpu/msm/kgsl.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c
index 8c8a51021e21..43ec8d8ff88b 100644
--- a/drivers/gpu/msm/kgsl.c
+++ b/drivers/gpu/msm/kgsl.c
@@ -917,17 +917,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);