public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Make kthread_stop() not oops when passed a bad pointer
@ 2008-08-05 13:55 Matthew Wilcox
  2008-08-05 15:57 ` Stefan Richter
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Matthew Wilcox @ 2008-08-05 13:55 UTC (permalink / raw)
  To: Linus Torvalds, Andrew Morton; +Cc: linux-kernel, Rusty Russell


Due to some botched error handling code in a driver I was writing, I
recently called kthread_stop(NULL).  It's terribly exciting to discover
that you've just oopsed while holding a mutex that's required in order
to shut down.  Make kthread_stop a little more robust against numbskulls
like me.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>

diff --git a/kernel/kthread.c b/kernel/kthread.c
index 96cff2f..06c3477 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -201,6 +201,9 @@ int kthread_stop(struct task_struct *k)
 {
 	int ret;
 
+	if (!k || IS_ERR(k))
+		return -EINVAL;
+
 	mutex_lock(&kthread_stop_lock);
 
 	/* It could exit after stop_info.k set, but before wake_up_process. */
-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-08-08 20:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-05 13:55 [PATCH] Make kthread_stop() not oops when passed a bad pointer Matthew Wilcox
2008-08-05 15:57 ` Stefan Richter
2008-08-05 16:22 ` Andrew Morton
2008-08-06  5:42   ` [PATCH][migration] Trivial cleanup MinChan Kim
2008-08-06 14:25     ` Christoph Lameter
2008-08-06  1:22 ` [PATCH] Make kthread_stop() not oops when passed a bad pointer Rusty Russell
2008-08-06 12:07   ` Matthew Wilcox
2008-08-06 20:48     ` Rusty Russell
2008-08-08 20:50       ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox