summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLynus Vaz <lvaz@codeaurora.org>2017-11-15 19:55:01 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2017-11-30 06:42:01 -0800
commitd8475cbda75c4bd616ae0548b49bad38778bf595 (patch)
tree1cc8c67967b126ce08786c93e5a1704f9438d188
parentc414a49eded39536e4e1a0c7ad7ab4370212dc22 (diff)
msm: kgsl: Fix the process sysfs refcounting
The kobject used for the process's sysfs node did not provide a release function, so it did not correctly implement the refcounting. Add a release callback so that we keep the process structure valid as long as the kobject is alive. Change-Id: I6db54092ed29ecd4d2f157188a4f1a5fc70f1edf Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
-rw-r--r--drivers/gpu/msm/kgsl_sharedmem.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/gpu/msm/kgsl_sharedmem.c b/drivers/gpu/msm/kgsl_sharedmem.c
index 143dac1a9170..4c54553e9977 100644
--- a/drivers/gpu/msm/kgsl_sharedmem.c
+++ b/drivers/gpu/msm/kgsl_sharedmem.c
@@ -127,12 +127,10 @@ static ssize_t mem_entry_sysfs_show(struct kobject *kobj,
ssize_t ret;
/*
- * 1. sysfs_remove_file waits for reads to complete before the node
- * is deleted.
- * 2. kgsl_process_init_sysfs takes a refcount to the process_private,
- * which is put at the end of kgsl_process_uninit_sysfs.
- * These two conditions imply that priv will not be freed until this
- * function completes, and no further locking is needed.
+ * kgsl_process_init_sysfs takes a refcount to the process_private,
+ * which is put when the kobj is released. This implies that priv will
+ * not be freed until this function completes, and no further locking
+ * is needed.
*/
priv = kobj ? container_of(kobj, struct kgsl_process_private, kobj) :
NULL;
@@ -145,12 +143,22 @@ static ssize_t mem_entry_sysfs_show(struct kobject *kobj,
return ret;
}
+static void mem_entry_release(struct kobject *kobj)
+{
+ struct kgsl_process_private *priv;
+
+ priv = container_of(kobj, struct kgsl_process_private, kobj);
+ /* Put the refcount we got in kgsl_process_init_sysfs */
+ kgsl_process_private_put(priv);
+}
+
static const struct sysfs_ops mem_entry_sysfs_ops = {
.show = mem_entry_sysfs_show,
};
static struct kobj_type ktype_mem_entry = {
.sysfs_ops = &mem_entry_sysfs_ops,
+ .release = &mem_entry_release,
};
static struct mem_entry_stats mem_stats[] = {
@@ -173,8 +181,6 @@ kgsl_process_uninit_sysfs(struct kgsl_process_private *private)
}
kobject_put(&private->kobj);
- /* Put the refcount we got in kgsl_process_init_sysfs */
- kgsl_process_private_put(private);
}
/**