[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>

authored by Patrick Caulfield and committed by Steven Whitehouse ba542e3b 26d83ded

+8 -1
+8 -1
fs/dlm/lockspace.c
··· 143 return a->store ? a->store(ls, buf, len) : len; 144 } 145 146 static struct sysfs_ops dlm_attr_ops = { 147 .show = dlm_attr_show, 148 .store = dlm_attr_store, ··· 157 static struct kobj_type dlm_ktype = { 158 .default_attrs = dlm_attrs, 159 .sysfs_ops = &dlm_attr_ops, 160 }; 161 162 static struct kset dlm_kset = { ··· 685 dlm_clear_members_gone(ls); 686 kfree(ls->ls_node_array); 687 kobject_unregister(&ls->ls_kobj); 688 - kfree(ls); 689 690 mutex_lock(&ls_lock); 691 ls_count--;
··· 143 return a->store ? a->store(ls, buf, len) : len; 144 } 145 146 + static void lockspace_kobj_release(struct kobject *k) 147 + { 148 + struct dlm_ls *ls = container_of(k, struct dlm_ls, ls_kobj); 149 + kfree(ls); 150 + } 151 + 152 static struct sysfs_ops dlm_attr_ops = { 153 .show = dlm_attr_show, 154 .store = dlm_attr_store, ··· 151 static struct kobj_type dlm_ktype = { 152 .default_attrs = dlm_attrs, 153 .sysfs_ops = &dlm_attr_ops, 154 + .release = lockspace_kobj_release, 155 }; 156 157 static struct kset dlm_kset = { ··· 678 dlm_clear_members_gone(ls); 679 kfree(ls->ls_node_array); 680 kobject_unregister(&ls->ls_kobj); 681 + /* The ls structure will be freed when the kobject is done with */ 682 683 mutex_lock(&ls_lock); 684 ls_count--;