From: Andrew Morton <akpm@linux-foundation.org>
To: Matthew Wilcox <matthew@wil.cx>
Cc: Linus Torvalds <torvalds@linuxfoundation.org>,
Andrew Morton <akpm@linuxfoundation.org>,
linux-kernel@vger.kernel.org,
Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH] Make kthread_stop() not oops when passed a bad pointer
Date: Tue, 5 Aug 2008 09:22:09 -0700 [thread overview]
Message-ID: <20080805092209.830f5d0a.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080805135559.GQ26461@parisc-linux.org>
On Tue, 5 Aug 2008 07:55:59 -0600 Matthew Wilcox <matthew@wil.cx> wrote:
>
> 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);
>
hrm.
a) as this is a programming error, the programmer would like it not
to be hidden. A WARN_ON() would address that.
b) there are many instances of
if (p)
kthread_stop(p);
which could now be simplified to
kthread_stop(p);
c) a) and b) are incompatible.
next prev parent reply other threads:[~2008-08-05 16:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=20080805092209.830f5d0a.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=akpm@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linuxfoundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox