Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: powernv: Fix unsafe notifiers

The PowerNV cpufreq driver registers two notifiers: one to catch
throttle messages from the OCC and one to bump the CPU frequency back
to normal before a reboot. Both require the cpufreq driver to be
registered in order to function since the notifier callbacks use
various cpufreq_*() functions.

Right now we register both notifiers before we've initialised the
driver. This seems to work, but we should head off any protential
problems by registering the notifiers after the driver is initialised.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200206062622.28235-2-oohall@gmail.com

authored by

Oliver O'Halloran and committed by
Michael Ellerman
966c08de d0a72efa

+5 -6
+5 -6
drivers/cpufreq/powernv-cpufreq.c
··· 1114 1114 if (rc) 1115 1115 goto out; 1116 1116 1117 - register_reboot_notifier(&powernv_cpufreq_reboot_nb); 1118 - opal_message_notifier_register(OPAL_MSG_OCC, &powernv_cpufreq_opal_nb); 1119 - 1120 1117 if (powernv_pstate_info.wof_enabled) 1121 1118 powernv_cpufreq_driver.boost_enabled = true; 1122 1119 else ··· 1122 1125 rc = cpufreq_register_driver(&powernv_cpufreq_driver); 1123 1126 if (rc) { 1124 1127 pr_info("Failed to register the cpufreq driver (%d)\n", rc); 1125 - goto cleanup_notifiers; 1128 + goto cleanup; 1126 1129 } 1127 1130 1128 1131 if (powernv_pstate_info.wof_enabled) 1129 1132 cpufreq_enable_boost_support(); 1130 1133 1134 + register_reboot_notifier(&powernv_cpufreq_reboot_nb); 1135 + opal_message_notifier_register(OPAL_MSG_OCC, &powernv_cpufreq_opal_nb); 1136 + 1131 1137 return 0; 1132 - cleanup_notifiers: 1133 - unregister_all_notifiers(); 1138 + cleanup: 1134 1139 clean_chip_info(); 1135 1140 out: 1136 1141 pr_info("Platform driver disabled. System does not support PState control\n");