aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-03 14:37:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-03 14:37:15 -0400
commit542a086ac72fb193cbc1b996963a572269e57743 (patch)
treeb137c08037cca4ffc8a156a891a01113b3b8edce /lib
parent1d1fdd95df681f0c065d90ffaafa215a0e8825e2 (diff)
parent1eeeef153c02f5856ec109fa532eb5f31c39f85c (diff)
Merge tag 'driver-core-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core patches from Greg KH: "Here's the big driver core pull request for 3.12-rc1. Lots of tiny changes here fixing up the way sysfs attributes are created, to try to make drivers simpler, and fix a whole class race conditions with creations of device attributes after the device was announced to userspace. All the various pieces are acked by the different subsystem maintainers" * tag 'driver-core-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (119 commits) firmware loader: fix pending_fw_head list corruption drivers/base/memory.c: introduce help macro to_memory_block dynamic debug: line queries failing due to uninitialized local variable sysfs: sysfs_create_groups returns a value. debugfs: provide debugfs_create_x64() when disabled rbd: convert bus code to use bus_groups firmware: dcdbas: use binary attribute groups sysfs: add sysfs_create/remove_groups for when SYSFS is not enabled driver core: add #include <linux/sysfs.h> to core files. HID: convert bus code to use dev_groups Input: serio: convert bus code to use drv_groups Input: gameport: convert bus code to use drv_groups driver core: firmware: use __ATTR_RW() driver core: core: use DEVICE_ATTR_RO driver core: bus: use DRIVER_ATTR_WO() driver core: create write-only attribute macros for devices and drivers sysfs: create __ATTR_WO() driver-core: platform: convert bus code to use dev_groups workqueue: convert bus code to use dev_groups MEI: convert bus code to use dev_groups ...
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig.debug19
-rw-r--r--lib/dynamic_debug.c2
-rw-r--r--lib/kobject.c22
3 files changed, 39 insertions, 4 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 1501aa553221..444e1c12fea9 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -981,6 +981,25 @@ config DEBUG_KOBJECT
981 If you say Y here, some extra kobject debugging messages will be sent 981 If you say Y here, some extra kobject debugging messages will be sent
982 to the syslog. 982 to the syslog.
983 983
984config DEBUG_KOBJECT_RELEASE
985 bool "kobject release debugging"
986 depends on DEBUG_KERNEL
987 help
988 kobjects are reference counted objects. This means that their
989 last reference count put is not predictable, and the kobject can
990 live on past the point at which a driver decides to drop it's
991 initial reference to the kobject gained on allocation. An
992 example of this would be a struct device which has just been
993 unregistered.
994
995 However, some buggy drivers assume that after such an operation,
996 the memory backing the kobject can be immediately freed. This
997 goes completely against the principles of a refcounted object.
998
999 If you say Y here, the kernel will delay the release of kobjects
1000 on the last reference count to improve the visibility of this
1001 kind of kobject release bug.
1002
984config HAVE_DEBUG_BUGVERBOSE 1003config HAVE_DEBUG_BUGVERBOSE
985 bool 1004 bool
986 1005
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 99fec3ae405a..c37aeacd7651 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -309,7 +309,7 @@ static int ddebug_parse_query(char *words[], int nwords,
309 struct ddebug_query *query, const char *modname) 309 struct ddebug_query *query, const char *modname)
310{ 310{
311 unsigned int i; 311 unsigned int i;
312 int rc; 312 int rc = 0;
313 313
314 /* check we have an even number of words */ 314 /* check we have an even number of words */
315 if (nwords % 2 != 0) { 315 if (nwords % 2 != 0) {
diff --git a/lib/kobject.c b/lib/kobject.c
index 4a1f33d43548..1d46c151a4ae 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -545,8 +545,8 @@ static void kobject_cleanup(struct kobject *kobj)
545 struct kobj_type *t = get_ktype(kobj); 545 struct kobj_type *t = get_ktype(kobj);
546 const char *name = kobj->name; 546 const char *name = kobj->name;
547 547
548 pr_debug("kobject: '%s' (%p): %s\n", 548 pr_debug("kobject: '%s' (%p): %s, parent %p\n",
549 kobject_name(kobj), kobj, __func__); 549 kobject_name(kobj), kobj, __func__, kobj->parent);
550 550
551 if (t && !t->release) 551 if (t && !t->release)
552 pr_debug("kobject: '%s' (%p): does not have a release() " 552 pr_debug("kobject: '%s' (%p): does not have a release() "
@@ -580,9 +580,25 @@ static void kobject_cleanup(struct kobject *kobj)
580 } 580 }
581} 581}
582 582
583#ifdef CONFIG_DEBUG_KOBJECT_RELEASE
584static void kobject_delayed_cleanup(struct work_struct *work)
585{
586 kobject_cleanup(container_of(to_delayed_work(work),
587 struct kobject, release));
588}
589#endif
590
583static void kobject_release(struct kref *kref) 591static void kobject_release(struct kref *kref)
584{ 592{
585 kobject_cleanup(container_of(kref, struct kobject, kref)); 593 struct kobject *kobj = container_of(kref, struct kobject, kref);
594#ifdef CONFIG_DEBUG_KOBJECT_RELEASE
595 pr_debug("kobject: '%s' (%p): %s, parent %p (delayed)\n",
596 kobject_name(kobj), kobj, __func__, kobj->parent);
597 INIT_DELAYED_WORK(&kobj->release, kobject_delayed_cleanup);
598 schedule_delayed_work(&kobj->release, HZ);
599#else
600 kobject_cleanup(kobj);
601#endif
586} 602}
587 603
588/** 604/**