Skip to content

Commit 3f9f8da

Browse files
guohanjunrafaeljw
authored andcommitted
cpuidle: sysfs: Fix the overlap for showing available governors
When showing the available governors, it's "%s " in scnprintf(), not "%s", so if the governor name has 15 characters, it will overlap with the later one, fix it by adding one more for the size. While we are at it, fix the minor coding style issue and remove the "/sizeof(char)" since sizeof(char) always equals 1. Signed-off-by: Hanjun Guo <[email protected]> Reviewed-by: Doug Smythies <[email protected]> Tested-by: Doug Smythies <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 8b7ce5e commit 3f9f8da

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/cpuidle/sysfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ static ssize_t show_available_governors(struct device *dev,
3535

3636
mutex_lock(&cpuidle_lock);
3737
list_for_each_entry(tmp, &cpuidle_governors, governor_list) {
38-
if (i >= (ssize_t) ((PAGE_SIZE/sizeof(char)) -
39-
CPUIDLE_NAME_LEN - 2))
38+
if (i >= (ssize_t) (PAGE_SIZE - (CPUIDLE_NAME_LEN + 2)))
4039
goto out;
41-
i += scnprintf(&buf[i], CPUIDLE_NAME_LEN, "%s ", tmp->name);
40+
41+
i += scnprintf(&buf[i], CPUIDLE_NAME_LEN + 1, "%s ", tmp->name);
4242
}
4343

4444
out:

0 commit comments

Comments
 (0)