diff options
author | Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> | 2014-05-17 13:20:57 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-05-19 20:56:00 -0400 |
commit | bd0c30e310d43c49debe380e344307b677e182a6 (patch) | |
tree | 72a0f45acd4f89842640fdc7eb32a838c8fb4123 | |
parent | 1efc563865dbc3710c5af7bc1540360a6d06192c (diff) |
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: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | drivers/macintosh/windfarm_pm121.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/macintosh/windfarm_pm121.c b/drivers/macintosh/windfarm_pm121.c index 7fe58b0ae8b4..b350fb86ff08 100644 --- a/drivers/macintosh/windfarm_pm121.c +++ b/drivers/macintosh/windfarm_pm121.c | |||
@@ -555,8 +555,18 @@ static void pm121_create_sys_fans(int loop_id) | |||
555 | pid_param.interval = PM121_SYS_INTERVAL; | 555 | pid_param.interval = PM121_SYS_INTERVAL; |
556 | pid_param.history_len = PM121_SYS_HISTORY_SIZE; | 556 | pid_param.history_len = PM121_SYS_HISTORY_SIZE; |
557 | pid_param.itarget = param->itarget; | 557 | pid_param.itarget = param->itarget; |
558 | pid_param.min = control->ops->get_min(control); | 558 | if(control) |
559 | pid_param.max = control->ops->get_max(control); | 559 | { |
560 | pid_param.min = control->ops->get_min(control); | ||
561 | pid_param.max = control->ops->get_max(control); | ||
562 | } else { | ||
563 | /* | ||
564 | * This is probably not the right!? | ||
565 | * Perhaps goto fail if control == NULL above? | ||
566 | */ | ||
567 | pid_param.min = 0; | ||
568 | pid_param.max = 0; | ||
569 | } | ||
560 | 570 | ||
561 | wf_pid_init(&pm121_sys_state[loop_id]->pid, &pid_param); | 571 | wf_pid_init(&pm121_sys_state[loop_id]->pid, &pid_param); |
562 | 572 | ||
@@ -571,7 +581,7 @@ static void pm121_create_sys_fans(int loop_id) | |||
571 | control the same control */ | 581 | control the same control */ |
572 | printk(KERN_WARNING "pm121: failed to set up %s loop " | 582 | printk(KERN_WARNING "pm121: failed to set up %s loop " |
573 | "setting \"%s\" to max speed.\n", | 583 | "setting \"%s\" to max speed.\n", |
574 | loop_names[loop_id], control->name); | 584 | loop_names[loop_id], control ? control->name : "uninitialized value"); |
575 | 585 | ||
576 | if (control) | 586 | if (control) |
577 | wf_control_set_max(control); | 587 | wf_control_set_max(control); |