public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Neil Horman <nhorman@tuxdriver.com>
To: Andrew Morton <akpm@osdl.org>
Cc: kernel-janitors@lists.osdl.org, linux-kernel@vger.kernel.org,
	torvalds@osdl.org, marcel@holtman.org, fpavlic@de.ibm.com,
	paulus@au.ibm.com, bcollins@debian.org, tony.luck@intel.com
Subject: Re: [KJ] (re) audit return code handling for kernel_thread [1/3]
Date: Sat, 29 Jul 2006 20:48:50 -0400	[thread overview]
Message-ID: <20060730004850.GA9344@localhost.localdomain> (raw)
In-Reply-To: <20060729170333.a45efeaf.akpm@osdl.org>

On Sat, Jul 29, 2006 at 05:03:33PM -0700, Andrew Morton wrote:
> On Sat, 29 Jul 2006 16:15:55 -0400
> Neil Horman <nhorman@tuxdriver.com> wrote:
> 
> > Patch to audit return code checking of kernel_thread.  These fixes correct those
> > callers who fail to check the return code of kernel_thread at all
> > 
> > 
> 
> Various people are running around converting open-coded kernel_thread
> callers over to the kthread API.  Generally that's a good thing, and error
> checking should be incorporated at that time.
> 
> So there's probably not a lot of point in making these changes now - it'd
> be better to work with the various subsystem owners on doing the kthread
> conversion.
> 
> > --- a/arch/s390/mm/cmm.c
> > +++ b/arch/s390/mm/cmm.c
> > @@ -161,7 +161,11 @@ cmm_thread(void *dummy)
> >  static void
> >  cmm_start_thread(void)
> >  {
> > -	kernel_thread(cmm_thread, NULL, 0);
> > +	if (kernel_thread(cmm_thread, NULL, 0) < 0) {
> > +		printk(KERN_WARNING "Could not start kernel thread at %s:%d\n",
> > +			__FUNCTION__,__LINE__);
> > +		clear_bit(0,&cmm_thread_active);
> > +	}
> >  }
> 
> This is OK as far as it goes.  But really we should propagate any failure
> back up to cmm_init() and fail the whole thing, rather than leaving the
> driver hanging around in a loaded-but-useless state.


Understood, new patch attached, that removes most of the additional failure to
check return code cases.  I've left the cmm_start_thread case and the
rfcomm_init cases as is, because the cmm_start_thread case is called
asynchronously from a work queue, fired from a timer, meaning we cannot
propogate the error to prevent the module from loading, and the rfcomm_init case
does precisely what you ask, in that it detects a failure to start the kernel
thread, and fails the module load if the thread creation fails.

Thanks & Regards
Neil

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>


 arch/s390/mm/cmm.c          |    6 +++++-
 net/bluetooth/rfcomm/core.c |    6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)


--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -161,7 +161,11 @@
 static void
 cmm_start_thread(void)
 {
-	kernel_thread(cmm_thread, NULL, 0);
+	if (kernel_thread(cmm_thread, NULL, 0) < 0) {
+		printk(KERN_WARNING "Could not start kernel thread at %s:%d\n",
+			__FUNCTION__,__LINE__);
+		clear_bit(0,&cmm_thread_active);
+	}
 }
 
 
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -2052,11 +2052,15 @@
 /* ---- Initialization ---- */
 static int __init rfcomm_init(void)
 {
+	int ret;
 	l2cap_load();
 
 	hci_register_cb(&rfcomm_cb);
 
-	kernel_thread(rfcomm_run, NULL, CLONE_KERNEL);
+	ret = kernel_thread(rfcomm_run, NULL, CLONE_KERNEL);
+	
+	if (ret < 0)
+		return ret;
 
 	class_create_file(bt_class, &class_attr_rfcomm_dlc);
 

  reply	other threads:[~2006-07-30  0:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-29 20:11 [KJ] (re) audit return code handling for kernel_thread [0/3] Neil Horman
2006-07-29 20:15 ` [KJ] (re) audit return code handling for kernel_thread [1/3] Neil Horman
2006-07-30  0:03   ` Andrew Morton
2006-07-30  0:48     ` Neil Horman [this message]
2006-07-30 21:39       ` Heiko Carstens
2006-07-31  9:17         ` Heiko Carstens
2006-07-29 20:18 ` [KJ] (re) audit return code handling for kernel_thread [2/3] Neil Horman
2006-07-29 20:20 ` [KJ] (re) audit return code handling for kernel_thread [3/3] Neil Horman

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=20060730004850.GA9344@localhost.localdomain \
    --to=nhorman@tuxdriver.com \
    --cc=akpm@osdl.org \
    --cc=bcollins@debian.org \
    --cc=fpavlic@de.ibm.com \
    --cc=kernel-janitors@lists.osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtman.org \
    --cc=paulus@au.ibm.com \
    --cc=tony.luck@intel.com \
    --cc=torvalds@osdl.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