sparc: Fix cleanup crash in bbc_envctrl_cleanup()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Tuesday, August 25, 2009 - 9:59 pm

Gitweb:     http://git.kernel.org/linus/14d87e6c399f3942d63dff41447ff08a615d9a6b
Commit:     14d87e6c399f3942d63dff41447ff08a615d9a6b
Parent:     8944146daa2c38dd85bc489d1b84fb9abc108837
Author:     David S. Miller <davem@davemloft.net>
AuthorDate: Fri Jul 17 10:28:19 2009 -0700
Committer:  David S. Miller <davem@davemloft.net>
CommitDate: Fri Jul 17 10:28:19 2009 -0700

    sparc: Fix cleanup crash in bbc_envctrl_cleanup()
    
    If kthread_run() fails or never gets to run we'll have NULL
    or a pointer encoded error in kenvctrld_task, rather than
    a legitimate task pointer.
    
    So this makes bbc_envctrl_cleanup() crash as it passed this
    bogus pointer into kthread_stop().
    
    Reported-by: BERTRAND Joël <joel.bertrand@systella.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/sbus/char/bbc_envctrl.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
index 15dab96..7c815d3 100644
--- a/drivers/sbus/char/bbc_envctrl.c
+++ b/drivers/sbus/char/bbc_envctrl.c
@@ -537,8 +537,12 @@ int bbc_envctrl_init(struct bbc_i2c_bus *bp)
 	}
 	if (temp_index != 0 && fan_index != 0) {
 		kenvctrld_task = kthread_run(kenvctrld, NULL, "kenvctrld");
-		if (IS_ERR(kenvctrld_task))
-			return PTR_ERR(kenvctrld_task);
+		if (IS_ERR(kenvctrld_task)) {
+			int err = PTR_ERR(kenvctrld_task);
+
+			kenvctrld_task = NULL;
+			return err;
+		}
 	}
 
 	return 0;
@@ -561,7 +565,8 @@ void bbc_envctrl_cleanup(struct bbc_i2c_bus *bp)
 	struct bbc_cpu_temperature *tp, *tpos;
 	struct bbc_fan_control *fp, *fpos;
 
-	kthread_stop(kenvctrld_task);
+	if (kenvctrld_task)
+		kthread_stop(kenvctrld_task);
 
 	list_for_each_entry_safe(tp, tpos, &bp->temps, bp_list) {
 		list_del(&tp->bp_list);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
sparc: Fix cleanup crash in bbc_envctrl_cleanup(), Linux Kernel Mailing ..., (Tue Aug 25, 9:59 pm)