Date: Thu, 31 Dec 2015 11:27:36 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r292986 - in head/sys/compat/linuxkpi/common: include/linux src Message-ID: <201512311127.tBVBRasi076295@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Thu Dec 31 11:27:36 2015 New Revision: 292986 URL: https://svnweb.freebsd.org/changeset/base/292986 Log: 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 Modified: head/sys/compat/linuxkpi/common/include/linux/cdev.h head/sys/compat/linuxkpi/common/src/linux_compat.c Modified: head/sys/compat/linuxkpi/common/include/linux/cdev.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/cdev.h Thu Dec 31 11:25:45 2015 (r292985) +++ head/sys/compat/linuxkpi/common/include/linux/cdev.h Thu Dec 31 11:27:36 2015 (r292986) @@ -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 cdev->dev = dev; cdev->cdev->si_drv1 = cdev; + kobject_get(cdev->kobj.parent); return (0); } Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_compat.c Thu Dec 31 11:25:45 2015 (r292985) +++ head/sys/compat/linuxkpi/common/src/linux_compat.c Thu Dec 31 11:27:36 2015 (r292986) @@ -157,7 +157,7 @@ kobject_add_complete(struct kobject *kob 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512311127.tBVBRasi076295>