Commit 14d87e6c authored by David S. Miller's avatar David S. Miller

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: default avatarBERTRAND Joël <joel.bertrand@systella.fr>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8944146d
......@@ -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,6 +565,7 @@ void bbc_envctrl_cleanup(struct bbc_i2c_bus *bp)
struct bbc_cpu_temperature *tp, *tpos;
struct bbc_fan_control *fp, *fpos;
if (kenvctrld_task)
kthread_stop(kenvctrld_task);
list_for_each_entry_safe(tp, tpos, &bp->temps, bp_list) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment