Skip to content

Commit

Permalink
sparc: Fix cleanup crash in bbc_envctrl_cleanup()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Jul 17, 2009
1 parent 8944146 commit 14d87e6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/sbus/char/bbc_envctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 14d87e6

Please sign in to comment.