diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-08-06 07:16:44 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-06 07:55:09 -0400 |
commit | e0d82a0a4e9841b787e6431ccfbb515546c55dc2 (patch) | |
tree | 5fe4ea05533ca0c60f90e27bd5fd9c3aacbcd668 /arch/powerpc | |
parent | af6af30c0fcd77e621638e53ef8b176bca8bd3b4 (diff) |
perf_counter/powerpc: Check oprofile_cpu_type for NULL before using it
If the current CPU doesn't support performance counters,
cur_cpu_spec->oprofile_cpu_type can be NULL. The current
perf_counter modules don't test for that case and would thus
crash at boot time.
Bug reported by David Woodhouse.
Reported-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Paul Mackerras <paulus@samba.org>
LKML-Reference: <19066.48028.446975.501454@cargo.ozlabs.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/kernel/mpc7450-pmu.c | 3 | ||||
-rw-r--r-- | arch/powerpc/kernel/power4-pmu.c | 3 | ||||
-rw-r--r-- | arch/powerpc/kernel/power5+-pmu.c | 5 | ||||
-rw-r--r-- | arch/powerpc/kernel/power5-pmu.c | 3 | ||||
-rw-r--r-- | arch/powerpc/kernel/power6-pmu.c | 3 | ||||
-rw-r--r-- | arch/powerpc/kernel/power7-pmu.c | 3 | ||||
-rw-r--r-- | arch/powerpc/kernel/ppc970-pmu.c | 5 |
7 files changed, 16 insertions, 9 deletions
diff --git a/arch/powerpc/kernel/mpc7450-pmu.c b/arch/powerpc/kernel/mpc7450-pmu.c index c244133c67a6..cc466d039af6 100644 --- a/arch/powerpc/kernel/mpc7450-pmu.c +++ b/arch/powerpc/kernel/mpc7450-pmu.c | |||
@@ -407,7 +407,8 @@ struct power_pmu mpc7450_pmu = { | |||
407 | 407 | ||
408 | static int init_mpc7450_pmu(void) | 408 | static int init_mpc7450_pmu(void) |
409 | { | 409 | { |
410 | if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc/7450")) | 410 | if (!cur_cpu_spec->oprofile_cpu_type || |
411 | strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc/7450")) | ||
411 | return -ENODEV; | 412 | return -ENODEV; |
412 | 413 | ||
413 | return register_power_pmu(&mpc7450_pmu); | 414 | return register_power_pmu(&mpc7450_pmu); |
diff --git a/arch/powerpc/kernel/power4-pmu.c b/arch/powerpc/kernel/power4-pmu.c index db90b0c5c27b..3c90a3d9173e 100644 --- a/arch/powerpc/kernel/power4-pmu.c +++ b/arch/powerpc/kernel/power4-pmu.c | |||
@@ -606,7 +606,8 @@ static struct power_pmu power4_pmu = { | |||
606 | 606 | ||
607 | static int init_power4_pmu(void) | 607 | static int init_power4_pmu(void) |
608 | { | 608 | { |
609 | if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power4")) | 609 | if (!cur_cpu_spec->oprofile_cpu_type || |
610 | strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power4")) | ||
610 | return -ENODEV; | 611 | return -ENODEV; |
611 | 612 | ||
612 | return register_power_pmu(&power4_pmu); | 613 | return register_power_pmu(&power4_pmu); |
diff --git a/arch/powerpc/kernel/power5+-pmu.c b/arch/powerpc/kernel/power5+-pmu.c index f4adca8e98a4..31918af3e355 100644 --- a/arch/powerpc/kernel/power5+-pmu.c +++ b/arch/powerpc/kernel/power5+-pmu.c | |||
@@ -678,8 +678,9 @@ static struct power_pmu power5p_pmu = { | |||
678 | 678 | ||
679 | static int init_power5p_pmu(void) | 679 | static int init_power5p_pmu(void) |
680 | { | 680 | { |
681 | if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5+") | 681 | if (!cur_cpu_spec->oprofile_cpu_type || |
682 | && strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5++")) | 682 | (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5+") |
683 | && strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5++"))) | ||
683 | return -ENODEV; | 684 | return -ENODEV; |
684 | 685 | ||
685 | return register_power_pmu(&power5p_pmu); | 686 | return register_power_pmu(&power5p_pmu); |
diff --git a/arch/powerpc/kernel/power5-pmu.c b/arch/powerpc/kernel/power5-pmu.c index 29b2c6c0e83a..867f6f663963 100644 --- a/arch/powerpc/kernel/power5-pmu.c +++ b/arch/powerpc/kernel/power5-pmu.c | |||
@@ -618,7 +618,8 @@ static struct power_pmu power5_pmu = { | |||
618 | 618 | ||
619 | static int init_power5_pmu(void) | 619 | static int init_power5_pmu(void) |
620 | { | 620 | { |
621 | if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5")) | 621 | if (!cur_cpu_spec->oprofile_cpu_type || |
622 | strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5")) | ||
622 | return -ENODEV; | 623 | return -ENODEV; |
623 | 624 | ||
624 | return register_power_pmu(&power5_pmu); | 625 | return register_power_pmu(&power5_pmu); |
diff --git a/arch/powerpc/kernel/power6-pmu.c b/arch/powerpc/kernel/power6-pmu.c index 09ae5bf5bda7..fa21890531da 100644 --- a/arch/powerpc/kernel/power6-pmu.c +++ b/arch/powerpc/kernel/power6-pmu.c | |||
@@ -537,7 +537,8 @@ static struct power_pmu power6_pmu = { | |||
537 | 537 | ||
538 | static int init_power6_pmu(void) | 538 | static int init_power6_pmu(void) |
539 | { | 539 | { |
540 | if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power6")) | 540 | if (!cur_cpu_spec->oprofile_cpu_type || |
541 | strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power6")) | ||
541 | return -ENODEV; | 542 | return -ENODEV; |
542 | 543 | ||
543 | return register_power_pmu(&power6_pmu); | 544 | return register_power_pmu(&power6_pmu); |
diff --git a/arch/powerpc/kernel/power7-pmu.c b/arch/powerpc/kernel/power7-pmu.c index 5a9f5cbd40a4..388cf57ad827 100644 --- a/arch/powerpc/kernel/power7-pmu.c +++ b/arch/powerpc/kernel/power7-pmu.c | |||
@@ -366,7 +366,8 @@ static struct power_pmu power7_pmu = { | |||
366 | 366 | ||
367 | static int init_power7_pmu(void) | 367 | static int init_power7_pmu(void) |
368 | { | 368 | { |
369 | if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7")) | 369 | if (!cur_cpu_spec->oprofile_cpu_type || |
370 | strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7")) | ||
370 | return -ENODEV; | 371 | return -ENODEV; |
371 | 372 | ||
372 | return register_power_pmu(&power7_pmu); | 373 | return register_power_pmu(&power7_pmu); |
diff --git a/arch/powerpc/kernel/ppc970-pmu.c b/arch/powerpc/kernel/ppc970-pmu.c index 833097ac45dc..75dccb71a043 100644 --- a/arch/powerpc/kernel/ppc970-pmu.c +++ b/arch/powerpc/kernel/ppc970-pmu.c | |||
@@ -488,8 +488,9 @@ static struct power_pmu ppc970_pmu = { | |||
488 | 488 | ||
489 | static int init_ppc970_pmu(void) | 489 | static int init_ppc970_pmu(void) |
490 | { | 490 | { |
491 | if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970") | 491 | if (!cur_cpu_spec->oprofile_cpu_type || |
492 | && strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970MP")) | 492 | (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970") |
493 | && strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970MP"))) | ||
493 | return -ENODEV; | 494 | return -ENODEV; |
494 | 495 | ||
495 | return register_power_pmu(&ppc970_pmu); | 496 | return register_power_pmu(&ppc970_pmu); |