summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2015-12-31 11:27:36 +0000
committerhselasky <hselasky@FreeBSD.org>2015-12-31 11:27:36 +0000
commitc5e1fb2b0fbc37a9e612bea86e0f53e6396e02ac (patch)
tree3179fd05a1c528a972768496ddc11f0b8600a014 /sys/compat
parent0219f2b937baf6515d4cd2bf7311adfbdfef2e20 (diff)
downloadFreeBSD-src-c5e1fb2b0fbc37a9e612bea86e0f53e6396e02ac.zip
FreeBSD-src-c5e1fb2b0fbc37a9e612bea86e0f53e6396e02ac.tar.gz
Make the kobject refcounting compliant with Linux. Refcounting on the
parent kobject cannot be factored out and must be done by the kobject consumers. MFC after: 1 week Sponsored by: Mellanox Technologies
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linuxkpi/common/include/linux/cdev.h7
-rw-r--r--sys/compat/linuxkpi/common/src/linux_compat.c5
2 files changed, 8 insertions, 4 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/cdev.h b/sys/compat/linuxkpi/common/include/linux/cdev.h
index 5d8962f..0f81099 100644
--- a/sys/compat/linuxkpi/common/include/linux/cdev.h
+++ b/sys/compat/linuxkpi/common/include/linux/cdev.h
@@ -54,21 +54,27 @@ static inline void
cdev_release(struct kobject *kobj)
{
struct linux_cdev *cdev;
+ struct kobject *parent;
cdev = container_of(kobj, struct linux_cdev, kobj);
+ parent = kobj->parent;
if (cdev->cdev)
destroy_dev(cdev->cdev);
kfree(cdev);
+ kobject_put(parent);
}
static inline void
cdev_static_release(struct kobject *kobj)
{
struct linux_cdev *cdev;
+ struct kobject *parent;
cdev = container_of(kobj, struct linux_cdev, kobj);
+ parent = kobj->parent;
if (cdev->cdev)
destroy_dev(cdev->cdev);
+ kobject_put(parent);
}
static struct kobj_type cdev_ktype = {
@@ -114,6 +120,7 @@ cdev_add(struct linux_cdev *cdev, dev_t dev, unsigned count)
cdev->dev = dev;
cdev->cdev->si_drv1 = cdev;
+ kobject_get(cdev->kobj.parent);
return (0);
}
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
index 91ec693..b57326a 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -157,7 +157,7 @@ kobject_add_complete(struct kobject *kobj, struct kobject *parent)
struct kobj_type *t;
int error;
- kobj->parent = kobject_get(parent);
+ kobj->parent = parent;
error = sysfs_create_dir(kobj);
if (error == 0 && kobj->ktype && kobj->ktype->default_attrs) {
struct attribute **attr;
@@ -198,9 +198,6 @@ kobject_release(struct kref *kref)
kobj = container_of(kref, struct kobject, kref);
sysfs_remove_dir(kobj);
- if (kobj->parent)
- kobject_put(kobj->parent);
- kobj->parent = NULL;
name = kobj->name;
if (kobj->ktype && kobj->ktype->release)
kobj->ktype->release(kobj);
OpenPOWER on IntegriCloud