All of lore.kernel.org
 help / color / mirror / Atom feed
From: Neil Horman <nhorman@tuxdriver.com>
To: kernel-janitors@lists.osdl.org, linux-kernel@vger.kernel.org,
	torvalds@osdl.org, akpm@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 [2/3]
Date: Sat, 29 Jul 2006 20:18:09 +0000	[thread overview]
Message-ID: <20060729201809.GC8574@localhost.localdomain> (raw)
In-Reply-To: <20060729201139.GA8574@localhost.localdomain>

Patch to audit return codes from kernel_thread.  This patch handles cases in
which the return code was stored for later interrogations, but the later checks
assumed that negative return codes were successful.

Thanks 
Neil

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


 arch/s390/mm/cmm.c             |    6 +++++-
 drivers/macintosh/adb.c        |    7 +++++--
 drivers/macintosh/therm_pm72.c |    5 ++++-
 3 files changed, 14 insertions(+), 4 deletions(-)


--- 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);
+	}
 }
 
 static void
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -137,7 +137,7 @@ #endif
 
 static __inline__ void adb_wait_ms(unsigned int ms)
 {
-	if (current->pid && adb_probe_task_pid &&
+	if (current->pid && (adb_probe_task_pid >= 0) &&
 	  adb_probe_task_pid = current->pid)
 		msleep(ms);
 	else
@@ -270,6 +270,9 @@ static void
 __adb_probe_task(void *data)
 {
 	adb_probe_task_pid = kernel_thread(adb_probe_task, NULL, SIGCHLD | CLONE_KERNEL);
+	if (adb_probe_task_pid < 0)
+		printk(KERN_WARNING "Could not start kernel thread at %s:%d\n",
+			__FUNCTION__,__LINE__);
 }
 
 static DECLARE_WORK(adb_reset_work, __adb_probe_task, NULL);
@@ -494,7 +497,7 @@ adb_request(struct adb_request *req, voi
 	 * block. Beware that the "done" callback will be overriden !
 	 */
 	if ((flags & ADBREQ_SYNC) &&
-	    (current->pid && adb_probe_task_pid &&
+	    (current->pid && (adb_probe_task_pid >= 0) &&
 	    adb_probe_task_pid = current->pid)) {
 		req->done = adb_probe_wakeup;
 		rc = adb_controller->send_request(req, 0);
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -1769,6 +1769,9 @@ static void start_control_loops(void)
 	init_completion(&ctrl_complete);
 
 	ctrl_task = kernel_thread(main_control_loop, NULL, SIGCHLD | CLONE_KERNEL);
+	if (ctrl_task < 0)
+		printk(KERN_CRIT "Could not start kernel thread at %s:%d\n",
+			__FUNCTION__, __LINE__);
 }
 
 /*
@@ -1776,7 +1779,7 @@ static void start_control_loops(void)
  */
 static void stop_control_loops(void)
 {
-	if (ctrl_task != 0)
+	if (ctrl_task >= 0)
 		wait_for_completion(&ctrl_complete);
 }
 

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

WARNING: multiple messages have this Message-ID (diff)
From: Neil Horman <nhorman@tuxdriver.com>
To: kernel-janitors@lists.osdl.org, linux-kernel@vger.kernel.org,
	torvalds@osdl.org, akpm@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 [2/3]
Date: Sat, 29 Jul 2006 16:18:09 -0400	[thread overview]
Message-ID: <20060729201809.GC8574@localhost.localdomain> (raw)
In-Reply-To: <20060729201139.GA8574@localhost.localdomain>

Patch to audit return codes from kernel_thread.  This patch handles cases in
which the return code was stored for later interrogations, but the later checks
assumed that negative return codes were successful.

Thanks 
Neil

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


 arch/s390/mm/cmm.c             |    6 +++++-
 drivers/macintosh/adb.c        |    7 +++++--
 drivers/macintosh/therm_pm72.c |    5 ++++-
 3 files changed, 14 insertions(+), 4 deletions(-)


--- 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);
+	}
 }
 
 static void
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -137,7 +137,7 @@ #endif
 
 static __inline__ void adb_wait_ms(unsigned int ms)
 {
-	if (current->pid && adb_probe_task_pid &&
+	if (current->pid && (adb_probe_task_pid >= 0) &&
 	  adb_probe_task_pid == current->pid)
 		msleep(ms);
 	else
@@ -270,6 +270,9 @@ static void
 __adb_probe_task(void *data)
 {
 	adb_probe_task_pid = kernel_thread(adb_probe_task, NULL, SIGCHLD | CLONE_KERNEL);
+	if (adb_probe_task_pid < 0)
+		printk(KERN_WARNING "Could not start kernel thread at %s:%d\n",
+			__FUNCTION__,__LINE__);
 }
 
 static DECLARE_WORK(adb_reset_work, __adb_probe_task, NULL);
@@ -494,7 +497,7 @@ adb_request(struct adb_request *req, voi
 	 * block. Beware that the "done" callback will be overriden !
 	 */
 	if ((flags & ADBREQ_SYNC) &&
-	    (current->pid && adb_probe_task_pid &&
+	    (current->pid && (adb_probe_task_pid >= 0) &&
 	    adb_probe_task_pid == current->pid)) {
 		req->done = adb_probe_wakeup;
 		rc = adb_controller->send_request(req, 0);
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -1769,6 +1769,9 @@ static void start_control_loops(void)
 	init_completion(&ctrl_complete);
 
 	ctrl_task = kernel_thread(main_control_loop, NULL, SIGCHLD | CLONE_KERNEL);
+	if (ctrl_task < 0)
+		printk(KERN_CRIT "Could not start kernel thread at %s:%d\n",
+			__FUNCTION__, __LINE__);
 }
 
 /*
@@ -1776,7 +1779,7 @@ static void start_control_loops(void)
  */
 static void stop_control_loops(void)
 {
-	if (ctrl_task != 0)
+	if (ctrl_task >= 0)
 		wait_for_completion(&ctrl_complete);
 }
 


  parent reply	other threads:[~2006-07-29 20:18 UTC|newest]

Thread overview: 16+ 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:11 ` Neil Horman
2006-07-29 20:15 ` [KJ] (re) audit return code handling for kernel_thread [1/3] Neil Horman
2006-07-29 20:15   ` Neil Horman
2006-07-30  0:03   ` Andrew Morton
2006-07-30  0:03     ` Andrew Morton
2006-07-30  0:48     ` Neil Horman
2006-07-30  0:48       ` Neil Horman
2006-07-30 21:39       ` Heiko Carstens
2006-07-30 21:39         ` Heiko Carstens
2006-07-31  9:17         ` Heiko Carstens
2006-07-31  9:17           ` Heiko Carstens
2006-07-29 20:18 ` Neil Horman [this message]
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
2006-07-29 20:20   ` 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=20060729201809.GC8574@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.