mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
x86_energy_perf_policy: Harden update_cpufreq_scaling_freq()
Protect update_cpufreq_scaling_freq() from buffer overflow if somehow it was called with a huge CPU number. Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
481006fbcb
commit
74bd795c99
|
|
@ -1167,12 +1167,12 @@ int ratio_2_sysfs_khz(int ratio)
|
|||
*/
|
||||
void update_cpufreq_scaling_freq(int is_max, int cpu, unsigned int ratio)
|
||||
{
|
||||
char pathname[64];
|
||||
char pathname[96];
|
||||
FILE *fp;
|
||||
int retval;
|
||||
int khz;
|
||||
|
||||
sprintf(pathname, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_%s_freq", cpu, is_max ? "max" : "min");
|
||||
snprintf(pathname, sizeof(pathname), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_%s_freq", cpu, is_max ? "max" : "min");
|
||||
|
||||
fp = fopen(pathname, "w");
|
||||
if (!fp) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user