login
Header Space

 
 

Re: NULL dereference OOPS on SysRq-w

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Dan Noe <dpn@...>
Cc: Linux Kernel Mailing List <linux-kernel@...>, <mingo@...>
Date: Monday, April 28, 2008 - 2:57 am

On Sun, Apr 27, 2008 at 02:36:42AM -0400, Dan Noe wrote:

[snip]


[snip]

I have a fix for the NULL pointer reference BUG, tested on my pc.
---

"m" will be NULL if seq_printf & seq_puts is called from sched_debug_show
Use SEQ_* macros to fix it 

Signed-off-by: Dave Young <hidave.darkstar@gmail.com>

---
include/linux/sched.h |   22 ++++++++++++++++++++++
kernel/sched_debug.c  |   12 ------------
kernel/sched_fair.c   |    6 +++---
3 files changed, 25 insertions(+), 15 deletions(-)

diff -upr linux/include/linux/sched.h linux.new/include/linux/sched.h
--- linux/include/linux/sched.h	2008-04-28 14:27:25.000000000 +0800
+++ linux.new/include/linux/sched.h	2008-04-28 14:37:45.000000000 +0800
@@ -2145,6 +2145,28 @@ static inline void migration_init(void)
 #define TASK_SIZE_OF(tsk)	TASK_SIZE
 #endif
 
+#ifdef CONFIG_SCHED_DEBUG
+/*
+ * This allows printing both to /proc/sched_debug and
+ * to the console
+ */
+#define SEQ_printf(m, x...)			\
+ do {						\
+	if (m)					\
+		seq_printf(m, x);		\
+	else					\
+		printk(x);			\
+ } while (0)
+
+#define SEQ_puts(m, x...)			\
+ do {						\
+	if (m)					\
+		seq_puts(m, x);			\
+	else					\
+		printk(x);			\
+ } while (0)
+#endif
+
 #endif /* __KERNEL__ */
 
 #endif
diff -upr linux/kernel/sched_debug.c linux.new/kernel/sched_debug.c
--- linux/kernel/sched_debug.c	2008-04-28 14:24:02.000000000 +0800
+++ linux.new/kernel/sched_debug.c	2008-04-28 14:37:32.000000000 +0800
@@ -17,18 +17,6 @@
 #include <linux/utsname.h>
 
 /*
- * This allows printing both to /proc/sched_debug and
- * to the console
- */
-#define SEQ_printf(m, x...)			\
- do {						\
-	if (m)					\
-		seq_printf(m, x);		\
-	else					\
-		printk(x);			\
- } while (0)
-
-/*
  * Ease the printing of nsec fields:
  */
 static long long nsec_high(unsigned long long nsec)
diff -upr linux/kernel/sched_fair.c linux.new/kernel/sched_fair.c
--- linux/kernel/sched_fair.c	2008-04-28 14:16:17.000000000 +0800
+++ linux.new/kernel/sched_fair.c	2008-04-28 14:37:24.000000000 +0800
@@ -1623,9 +1623,9 @@ print_cfs_rq_tasks(struct seq_file *m, s
 		int i;
 
 		for (i = depth; i; i--)
-			seq_puts(m, "  ");
+			SEQ_puts(m, "  ");
 
-		seq_printf(m, "%lu %s %lu\n",
+		SEQ_printf(m, "%lu %s %lu\n",
 				se->load.weight,
 				entity_is_task(se) ? "T" : "G",
 				calc_delta_weight(SCHED_LOAD_SCALE, se)
@@ -1643,7 +1643,7 @@ static void print_cfs_stats(struct seq_f
 	for_each_leaf_cfs_rq(cpu_rq(cpu), cfs_rq)
 		print_cfs_rq(m, cpu, cfs_rq);
 
-	seq_printf(m, "\nWeight tree:\n");
+	SEQ_printf(m, "\nWeight tree:\n");
 	print_cfs_rq_tasks(m, &cpu_rq(cpu)->cfs, 1);
 	rcu_read_unlock();
 }
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
NULL dereference OOPS on SysRq-w, Dan Noe, (Sun Apr 27, 2:36 am)
Re: NULL dereference OOPS on SysRq-w, Dave Young, (Mon Apr 28, 2:57 am)
Re: NULL dereference OOPS on SysRq-w, Dan Noe, (Mon Apr 28, 3:01 am)
Re: NULL dereference OOPS on SysRq-w, Dave Young, (Mon Apr 28, 3:08 am)
Re: NULL dereference OOPS on SysRq-w, Dave Young, (Mon Apr 28, 3:26 am)
speck-geostationary