Skip to contentSkip to conversation

PM: intel_powerclamp: off by one in start_power_clamp()

PATCH Applied Dan Carpenter 2 participants 2 messages Jan 24, 2013 – Feb 4, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 5100ee96.xoiaCavCYxXgoSIK%[email protected]

#1 lore raw

PATCH 1/1 PM: intel_powerclamp: off by one in start_power_clamp()

This value has already been clamped correctly to 0 through 49 in powerclamp_set_cur_state() so this patch doesn't actually change anything. But we should fix it anyway for consistency.

set_target_ratio is used as an offset into an array with MAX_TARGET_RATIO (50) elements.

drivers/thermal/intel_powerclamp.c +1 -1
index a85ff38..ab3ed90 100644
@@ -504,7 +504,7 @@ static int start_power_clamp(void)
 		return -EINVAL;
 	}
 
-	set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO);
+	set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO - 1);
 	/* prevent cpu hotplug */
 	get_online_cpus();
 
reviewer Applied
#2 lore raw
Quoted 8 lines · Dan Carpenter

This value has already been clamped correctly to 0 through 49 in powerclamp_set_cur_state() so this patch doesn't actually change anything. But we should fix it anyway for consistency.

set_target_ratio is used as an offset into an array with MAX_TARGET_RATIO (50) elements.

applied to thermal-next.

BTW, Jacob, it would be good to get your comments on this as you're the author of this driver.

thanks,
rui

Quoted 14 lines
drivers/thermal/intel_powerclamp.c +1 -1
index a85ff38..ab3ed90 100644
@@ -504,7 +504,7 @@ static int start_power_clamp(void)
 		return -EINVAL;
 	}
 
-	set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO);
+	set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO - 1);
 	/* prevent cpu hotplug */
 	get_online_cpus();