Skip to content

Commit a7b50ab

Browse files
mjkravetztorvalds
authored andcommitted
selftests/vm/compaction_test: fix write to restore nr_hugepages
The write at the end of the test to restore nr_hugepages to its previous value is failing. This is because it is trying to write the number of bytes in the char array as opposed to the number of bytes in the string. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Mike Kravetz <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Sri Jayaramappa <[email protected]> Cc: Eric B Munson <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9df10fb commit a7b50ab

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/vm/compaction_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size)
136136
printf("No of huge pages allocated = %d\n",
137137
(atoi(nr_hugepages)));
138138

139-
if (write(fd, initial_nr_hugepages, sizeof(initial_nr_hugepages))
139+
if (write(fd, initial_nr_hugepages, strlen(initial_nr_hugepages))
140140
!= strlen(initial_nr_hugepages)) {
141141
perror("Failed to write to /proc/sys/vm/nr_hugepages\n");
142142
goto close_fd;

0 commit comments

Comments
 (0)