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

PM / QoS: Improve sysfs pm_qos_latency_tolerance validation

Negative values are special. Don't let users write them directly.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Andrew Lutomirski and committed by
Rafael J. Wysocki
ee061da8 e5517c2a

+5 -1
+5 -1
drivers/base/power/sysfs.c
··· 263 263 s32 value; 264 264 int ret; 265 265 266 - if (kstrtos32(buf, 0, &value)) { 266 + if (kstrtos32(buf, 0, &value) == 0) { 267 + /* Users can't write negative values directly */ 268 + if (value < 0) 269 + return -EINVAL; 270 + } else { 267 271 if (!strcmp(buf, "auto") || !strcmp(buf, "auto\n")) 268 272 value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT; 269 273 else if (!strcmp(buf, "any") || !strcmp(buf, "any\n"))