aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/kgdbts.c
diff options
context:
space:
mode:
authorDongdong Deng <dongdong.deng@windriver.com>2010-08-30 22:06:00 -0400
committerJason Wessel <jason.wessel@windriver.com>2010-10-29 14:14:41 -0400
commit4dacd5c073150cd78dfb6004cbfa71986f0258a4 (patch)
tree7da8bd47cc31480a44b579d37290339021d11162 /drivers/misc/kgdbts.c
parentd7ba979d45272385ce0fdf141d922e61ff48e07b (diff)
kgdbts: prevent re-entry to kgdbts before it unregisters
The "kgdb_connected" variable of debug_core just indicates whether or not kgdbts is connected to the debug_core. It does not completely prevent a script from trying invoke kgdbts again and possibly crashing the system (see Call Trace below). The configured variable in kgtbts can be used instead of kgdb_connected instead of kgdb_connected. The cleanup_kgdbts() can also be removed because there is no possible way to build kgdbts as a kernel module that you could unload with rmmod. Call Trace: ----------------------------------------------------------------- root:/$ echo kgdbts=V1S1000 > /sys/module/kgdbts/parameters/kgdbts kgdb: Unregistered I/O driver kgdbts, debugger disabled. ------------[ cut here ]------------ WARNING: at kernel/debug/debug_core.c:1002 kgdb_unregister_io_module+0xec/0x100() Hardware name: Moon Creek platform Modules linked in: Pid: 664, comm: sh Not tainted 2.6.34.1-WR4.0.0.0_standard #58 Call Trace: [<c103b1ed>] warn_slowpath_common+0x6d/0xa0 [<c1079fdc>] ? kgdb_unregister_io_module+0xec/0x100 [<c1079fdc>] ? kgdb_unregister_io_module+0xec/0x100 [<c10544e0>] ? param_attr_store+0x0/0x20 [<c103b235>] warn_slowpath_null+0x15/0x20 [<c1079fdc>] kgdb_unregister_io_module+0xec/0x100 [<c124e4ea>] cleanup_kgdbts+0x1a/0x20 [<c124eced>] param_set_kgdbts_var+0x6d/0xb0 [<c124ec80>] ? param_set_kgdbts_var+0x0/0xb0 [<c10544f7>] param_attr_store+0x17/0x20 [<c105457c>] module_attr_store+0x2c/0x40 [<c111fe84>] sysfs_write_file+0x94/0xf0 [<c10d42f6>] vfs_write+0x96/0x130 [<c111fdf0>] ? sysfs_write_file+0x0/0xf0 [<c10d44d6>] sys_write+0x46/0xd0 [<c13bf329>] system_call_done+0x0/0x4 ---[ end trace 4eb028c6ee43154c ]--- kgdb: Unregistered I/O driver kgdbts, debugger disabled. ----------------------------------------------------------------- [jason.wessel@windriver.com: remove cleanup_kgdbts() ] Signed-off-by: Dongdong Deng <dongdong.deng@windriver.com> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Diffstat (limited to 'drivers/misc/kgdbts.c')
-rw-r--r--drivers/misc/kgdbts.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
index 72450237a0f4..59c118c19a91 100644
--- a/drivers/misc/kgdbts.c
+++ b/drivers/misc/kgdbts.c
@@ -1044,12 +1044,6 @@ static int __init init_kgdbts(void)
1044 return configure_kgdbts(); 1044 return configure_kgdbts();
1045} 1045}
1046 1046
1047static void cleanup_kgdbts(void)
1048{
1049 if (configured == 1)
1050 kgdb_unregister_io_module(&kgdbts_io_ops);
1051}
1052
1053static int kgdbts_get_char(void) 1047static int kgdbts_get_char(void)
1054{ 1048{
1055 int val = 0; 1049 int val = 0;
@@ -1081,10 +1075,8 @@ static int param_set_kgdbts_var(const char *kmessage, struct kernel_param *kp)
1081 return 0; 1075 return 0;
1082 } 1076 }
1083 1077
1084 if (kgdb_connected) { 1078 if (configured == 1) {
1085 printk(KERN_ERR 1079 printk(KERN_ERR "kgdbts: ERROR: Already configured and running.\n");
1086 "kgdbts: Cannot reconfigure while KGDB is connected.\n");
1087
1088 return -EBUSY; 1080 return -EBUSY;
1089 } 1081 }
1090 1082
@@ -1093,9 +1085,6 @@ static int param_set_kgdbts_var(const char *kmessage, struct kernel_param *kp)
1093 if (config[len - 1] == '\n') 1085 if (config[len - 1] == '\n')
1094 config[len - 1] = '\0'; 1086 config[len - 1] = '\0';
1095 1087
1096 if (configured == 1)
1097 cleanup_kgdbts();
1098
1099 /* Go and configure with the new params. */ 1088 /* Go and configure with the new params. */
1100 return configure_kgdbts(); 1089 return configure_kgdbts();
1101} 1090}
@@ -1123,7 +1112,6 @@ static struct kgdb_io kgdbts_io_ops = {
1123}; 1112};
1124 1113
1125module_init(init_kgdbts); 1114module_init(init_kgdbts);
1126module_exit(cleanup_kgdbts);
1127module_param_call(kgdbts, param_set_kgdbts_var, param_get_string, &kps, 0644); 1115module_param_call(kgdbts, param_set_kgdbts_var, param_get_string, &kps, 0644);
1128MODULE_PARM_DESC(kgdbts, "<A|V1|V2>[F#|S#][N#]"); 1116MODULE_PARM_DESC(kgdbts, "<A|V1|V2>[F#|S#][N#]");
1129MODULE_DESCRIPTION("KGDB Test Suite"); 1117MODULE_DESCRIPTION("KGDB Test Suite");