diff options
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/processor_throttling.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 8728782aad3b..53345dbc5027 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -1232,7 +1232,10 @@ static ssize_t acpi_processor_write_throttling(struct file *file, | |||
1232 | int result = 0; | 1232 | int result = 0; |
1233 | struct seq_file *m = file->private_data; | 1233 | struct seq_file *m = file->private_data; |
1234 | struct acpi_processor *pr = m->private; | 1234 | struct acpi_processor *pr = m->private; |
1235 | char state_string[12] = { '\0' }; | 1235 | char state_string[5] = ""; |
1236 | char *charp = NULL; | ||
1237 | size_t state_val = 0; | ||
1238 | char tmpbuf[5] = ""; | ||
1236 | 1239 | ||
1237 | if (!pr || (count > sizeof(state_string) - 1)) | 1240 | if (!pr || (count > sizeof(state_string) - 1)) |
1238 | return -EINVAL; | 1241 | return -EINVAL; |
@@ -1241,10 +1244,23 @@ static ssize_t acpi_processor_write_throttling(struct file *file, | |||
1241 | return -EFAULT; | 1244 | return -EFAULT; |
1242 | 1245 | ||
1243 | state_string[count] = '\0'; | 1246 | state_string[count] = '\0'; |
1247 | if ((count > 0) && (state_string[count-1] == '\n')) | ||
1248 | state_string[count-1] = '\0'; | ||
1244 | 1249 | ||
1245 | result = acpi_processor_set_throttling(pr, | 1250 | charp = state_string; |
1246 | simple_strtoul(state_string, | 1251 | if ((state_string[0] == 't') || (state_string[0] == 'T')) |
1247 | NULL, 0)); | 1252 | charp++; |
1253 | |||
1254 | state_val = simple_strtoul(charp, NULL, 0); | ||
1255 | if (state_val >= pr->throttling.state_count) | ||
1256 | return -EINVAL; | ||
1257 | |||
1258 | snprintf(tmpbuf, 5, "%d", state_val); | ||
1259 | |||
1260 | if (strcmp(tmpbuf, charp) != 0) | ||
1261 | return -EINVAL; | ||
1262 | |||
1263 | result = acpi_processor_set_throttling(pr, state_val); | ||
1248 | if (result) | 1264 | if (result) |
1249 | return result; | 1265 | return result; |
1250 | 1266 | ||