aboutsummaryrefslogtreecommitdiffstats
path: root/driver/kobject-warn.patch
blob: 978b3aa5b6ade867cb2b8595b5711a1ddd14419f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From: gregkh@suse.de
Subject: kobject warning stuff

Good for development, don't push it to mainline as there are too many false positives.


Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 lib/kobject.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- gregkh-2.6.orig/lib/kobject.c
+++ gregkh-2.6/lib/kobject.c
@@ -126,6 +126,7 @@ char *kobject_get_path(struct kobject *k
  */
 void kobject_init(struct kobject * kobj)
 {
+	WARN_ON(atomic_read(&kobj->kref.refcount));
 	kref_init(&kobj->kref);
 	INIT_LIST_HEAD(&kobj->entry);
 	init_waitqueue_head(&kobj->poll);
@@ -362,6 +363,12 @@ void kobject_cleanup(struct kobject * ko
 	kobj->k_name = NULL;
 	if (t && t->release)
 		t->release(kobj);
+	else
+		pr_debug("kobject '%s' does not have a release() function, "
+			"if this is not a directory kobject, it is broken "
+			"and must be fixed.\n",
+			kobj->name);
+
 	if (s)
 		kset_put(s);
 	if (parent)