From: Konstantin Khlebnikov <khlebnikov@openvz.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 02/12] driver core: add debug-objects debug for device-drivers
Date: Fri, 14 Dec 2012 15:02:33 +0400 [thread overview]
Message-ID: <20121214110232.11019.91506.stgit@zurg> (raw)
In-Reply-To: <20121214110229.11019.63713.stgit@zurg>
CONFIG_DEBUG_OBJECTS_DRIVERS together with CONFIG_DEBUG_OBJECTS_FREE can catch
unloading device driver modules without proper unregistering.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
drivers/base/driver.c | 34 ++++++++++++++++++++++++++++++++++
lib/Kconfig.debug | 7 +++++++
2 files changed, 41 insertions(+)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 974e301..7eec027 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -15,8 +15,40 @@
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/string.h>
+#include <linux/debugobjects.h>
#include "base.h"
+#ifdef CONFIG_DEBUG_OBJECTS_DRIVERS
+
+static void * debug_driver_hint(void *addr)
+{
+ struct device_driver *drv = addr;
+
+ return drv->probe;
+}
+
+struct debug_obj_descr driver_debug_descr = {
+ .name = "device_driver",
+ .debug_hint = debug_driver_hint,
+};
+
+static inline void debug_driver_register(struct device_driver *drv)
+{
+ debug_object_init(drv, &driver_debug_descr);
+ debug_object_activate(drv, &driver_debug_descr);
+}
+
+static inline void debug_driver_unregister(struct device_driver *drv)
+{
+ debug_object_deactivate(drv, &driver_debug_descr);
+ debug_object_free(drv, &driver_debug_descr);
+}
+
+#else /* CONFIG_DEBUG_OBJECTS_DRIVERS */
+static inline void debug_driver_register(struct device_driver *drv) { }
+static inline void debug_driver_unregister(struct device_driver *drv) { }
+#endif /* CONFIG_DEBUG_OBJECTS_DRIVERS */
+
static struct device *next_device(struct klist_iter *i)
{
struct klist_node *n = klist_next(i);
@@ -190,6 +222,7 @@ int driver_register(struct device_driver *drv)
return ret;
}
kobject_uevent(&drv->p->kobj, KOBJ_ADD);
+ debug_driver_register(drv);
return ret;
}
@@ -209,6 +242,7 @@ void driver_unregister(struct device_driver *drv)
}
driver_remove_groups(drv, drv->groups);
bus_remove_driver(drv);
+ debug_driver_unregister(drv);
}
EXPORT_SYMBOL_GPL(driver_unregister);
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 3a35309..f5aee2d 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -404,6 +404,13 @@ config DEBUG_OBJECTS_PERCPU_COUNTER
percpu counter routines to track the life time of percpu counter
objects and validate the percpu counter operations.
+config DEBUG_OBJECTS_DRIVERS
+ bool "Debug device driver objects"
+ depends on DEBUG_OBJECTS
+ help
+ Enable this to turn on debugging device drivers structures. Together
+ with DEBUG_OBJECTS_FREE this can catch freeing registered drivers.
+
config DEBUG_OBJECTS_ENABLE_DEFAULT
int "debug_objects bootup default value (0-1)"
range 0 1
next prev parent reply other threads:[~2012-12-14 11:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-14 11:02 [PATCH 01/12] tools/testing/modules: introduce test which loads/unloads random modules Konstantin Khlebnikov
2012-12-14 11:02 ` Konstantin Khlebnikov [this message]
2012-12-14 11:02 ` [PATCH 03/12] mISDN: fix race in timer canceling on module unloading Konstantin Khlebnikov
2012-12-14 18:16 ` David Miller
2012-12-14 11:02 ` [PATCH 04/12] pps: pps_parport: fix oops " Konstantin Khlebnikov
2012-12-14 11:02 ` [PATCH 05/12] staging: vme_pio2: " Konstantin Khlebnikov
2012-12-17 12:01 ` Martyn Welch
2012-12-14 11:02 ` [PATCH 06/12] media/rc: fix oops on unloading module rc-core Konstantin Khlebnikov
2012-12-14 11:02 ` [PATCH 07/12] stmmac: fix platform driver unregistering Konstantin Khlebnikov
2012-12-14 18:16 ` David Miller
2012-12-14 11:02 ` [PATCH 08/12] bonding: do not cancel works in bond_uninit() Konstantin Khlebnikov
2012-12-14 18:16 ` David Miller
2012-12-14 11:02 ` [PATCH 09/12] pps: fix device destruction ordering Konstantin Khlebnikov
2012-12-14 11:03 ` [PATCH 10/12] mac802154: fix destructon ordering for ieee802154 devices Konstantin Khlebnikov
2012-12-14 18:16 ` David Miller
2012-12-14 11:03 ` [PATCH 11/12] firmware/dmi-sysfs: fix sysfs warning on module unload Konstantin Khlebnikov
2012-12-14 11:03 ` [PATCH 12/12] edac: fix kernel panic on module unloading Konstantin Khlebnikov
2012-12-14 11:26 ` Alan Cox
2012-12-14 11:50 ` Borislav Petkov
2012-12-14 11:55 ` Konstantin Khlebnikov
2012-12-14 13:26 ` Alan Cox
2012-12-15 17:53 ` Borislav Petkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121214110232.11019.91506.stgit@zurg \
--to=khlebnikov@openvz.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.