mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-10 07:10:27 +00:00
[DLM] Fix kref_put oops
This patch fixes the recounting on the lockspace kobject. Previously the lockspace was freed while userspace could have had a reference to one of its sysfs files, causing an oops in kref_put. Now the lockspace kfree is moved into the kobject release() function Signed-Off-By: Patrick Caulfield <pcaulfie@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
parent
26d83dedf6
commit
ba542e3b92
@ -143,6 +143,12 @@ static ssize_t dlm_attr_store(struct kobject *kobj, struct attribute *attr,
|
|||||||
return a->store ? a->store(ls, buf, len) : len;
|
return a->store ? a->store(ls, buf, len) : len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void lockspace_kobj_release(struct kobject *k)
|
||||||
|
{
|
||||||
|
struct dlm_ls *ls = container_of(k, struct dlm_ls, ls_kobj);
|
||||||
|
kfree(ls);
|
||||||
|
}
|
||||||
|
|
||||||
static struct sysfs_ops dlm_attr_ops = {
|
static struct sysfs_ops dlm_attr_ops = {
|
||||||
.show = dlm_attr_show,
|
.show = dlm_attr_show,
|
||||||
.store = dlm_attr_store,
|
.store = dlm_attr_store,
|
||||||
@ -151,6 +157,7 @@ static struct sysfs_ops dlm_attr_ops = {
|
|||||||
static struct kobj_type dlm_ktype = {
|
static struct kobj_type dlm_ktype = {
|
||||||
.default_attrs = dlm_attrs,
|
.default_attrs = dlm_attrs,
|
||||||
.sysfs_ops = &dlm_attr_ops,
|
.sysfs_ops = &dlm_attr_ops,
|
||||||
|
.release = lockspace_kobj_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct kset dlm_kset = {
|
static struct kset dlm_kset = {
|
||||||
@ -678,7 +685,7 @@ static int release_lockspace(struct dlm_ls *ls, int force)
|
|||||||
dlm_clear_members_gone(ls);
|
dlm_clear_members_gone(ls);
|
||||||
kfree(ls->ls_node_array);
|
kfree(ls->ls_node_array);
|
||||||
kobject_unregister(&ls->ls_kobj);
|
kobject_unregister(&ls->ls_kobj);
|
||||||
kfree(ls);
|
/* The ls structure will be freed when the kobject is done with */
|
||||||
|
|
||||||
mutex_lock(&ls_lock);
|
mutex_lock(&ls_lock);
|
||||||
ls_count--;
|
ls_count--;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user