Skip to contentSkip to conversation

thermal: intel: powerclamp: Reject invalid window_size values

PATCH Applied Thorsten Blum 2 participants 2 messages Aug 15 – Sep 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: intel: powerclamp: Reject invalid window_size values

window_size_set() sets ret to -EINVAL if new_window_size is outside the valid range, but then falls through and still updates window_size to the clamped value.

Return -EINVAL immediately and do not update window_size. Also drop the now-redundant clamp() call.

Fixes d6d71ee4a14a ("PM: Introduce Intel PowerClamp Driver")
---
 drivers/thermal/intel/intel_powerclamp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/intel/intel_powerclamp.c +2 -1
index bd7fd98dc310..8026651133d5 100644
@@ -289,9 +289,10 @@ static int window_size_set(const char *arg, const struct kernel_param *kp)
 		pr_err("Out of recommended window size %lu, between 2-10\n",
 			new_window_size);
 		ret = -EINVAL;
+		goto exit_win;
 	}
 
-	window_size = clamp(new_window_size, 2ul, 10ul);
+	window_size = new_window_size;
 	smp_mb();
 
 exit_win:
maintainer Applied
#1 lore raw
Quoted 21 lines · Thorsten Blum

window_size_set() sets ret to -EINVAL if new_window_size is outside the valid range, but then falls through and still updates window_size to the clamped value.

Return -EINVAL immediately and do not update window_size. Also drop the now-redundant clamp() call.

Fixes d6d71ee4a14a ("PM: Introduce Intel PowerClamp Driver")
---
 drivers/thermal/intel/intel_powerclamp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/intel/intel_powerclamp.c +0 -0
index bd7fd98dc310..8026651133d5 100644
@@ -289,9 +289,10 @@ static int window_size_set(const char *arg, const struct kernel_param *kp)
                pr_err("Out of recommended window size %lu, between 2-10\n",

drivers/thermal/intel/intel_powerclamp.c static int window_size_set(const char *arg, const struct kernel_param *kp) · line 298

Quoted 10 lines
drivers/thermal/intel/intel_powerclamp.c +2 -1
                        new_window_size);
                ret = -EINVAL;
+               goto exit_win;
        }
 
-       window_size = clamp(new_window_size, 2ul, 10ul);
+       window_size = new_window_size;
        smp_mb();
 
 exit_win:

Applied as 7.4 material, thanks!