Commit bd0c30e3 authored by Rickard Strandqvist's avatar Rickard Strandqvist Committed by Benjamin Herrenschmidt

macintosh/windfarm_pm121.c: Fix for possible null pointer dereference

There is otherwise a risk of a possible null pointer dereference.

Was largely found by using a static code analysis program called cppcheck.
Signed-off-by: default avatarRickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 1efc5638
...@@ -555,8 +555,18 @@ static void pm121_create_sys_fans(int loop_id) ...@@ -555,8 +555,18 @@ static void pm121_create_sys_fans(int loop_id)
pid_param.interval = PM121_SYS_INTERVAL; pid_param.interval = PM121_SYS_INTERVAL;
pid_param.history_len = PM121_SYS_HISTORY_SIZE; pid_param.history_len = PM121_SYS_HISTORY_SIZE;
pid_param.itarget = param->itarget; pid_param.itarget = param->itarget;
pid_param.min = control->ops->get_min(control); if(control)
pid_param.max = control->ops->get_max(control); {
pid_param.min = control->ops->get_min(control);
pid_param.max = control->ops->get_max(control);
} else {
/*
* This is probably not the right!?
* Perhaps goto fail if control == NULL above?
*/
pid_param.min = 0;
pid_param.max = 0;
}
wf_pid_init(&pm121_sys_state[loop_id]->pid, &pid_param); wf_pid_init(&pm121_sys_state[loop_id]->pid, &pid_param);
...@@ -571,7 +581,7 @@ static void pm121_create_sys_fans(int loop_id) ...@@ -571,7 +581,7 @@ static void pm121_create_sys_fans(int loop_id)
control the same control */ control the same control */
printk(KERN_WARNING "pm121: failed to set up %s loop " printk(KERN_WARNING "pm121: failed to set up %s loop "
"setting \"%s\" to max speed.\n", "setting \"%s\" to max speed.\n",
loop_names[loop_id], control->name); loop_names[loop_id], control ? control->name : "uninitialized value");
if (control) if (control)
wf_control_set_max(control); wf_control_set_max(control);
......
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