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

Configure Feed

Select the types of activity you want to include in your feed.

selftests/mm/uffd: initialize char variable to Null

In "uffd-stress.c" & "uffd-unit-tests.c". address of char variable having
garbage value (uninitialized) is passed to 'write' syscall triggers
warning.

uffd-stress.c:246:39: warning: variable 'c' is uninitialized when
passed as a const pointer argument here
[-Wuninitialized-const-pointer]

uffd-unit-tests.c:581:31: warning: variable 'c' is uninitialized
when passed as a const pointer argument here
[-Wuninitialized-const-pointer]

so the fix is to assign char variable to '\0' to prevent writing of
garbage value.

Link: https://lkml.kernel.org/r/20251126160830.52124-1-ankitkhushwaha.linux@gmail.com
Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Bill Wendling <morbo@google.com>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Ankit Khushwaha and committed by
Andrew Morton
0384c8ea f65372cd

+5 -5
+1 -1
tools/testing/selftests/mm/uffd-stress.c
··· 241 241 return 1; 242 242 243 243 for (cpu = 0; cpu < gopts->nr_parallel; cpu++) { 244 - char c; 244 + char c = '\0'; 245 245 if (bounces & BOUNCE_POLL) { 246 246 if (write(gopts->pipefd[cpu*2+1], &c, 1) != 1) 247 247 err("pipefd write error");
+4 -4
tools/testing/selftests/mm/uffd-unit-tests.c
··· 543 543 { 544 544 unsigned long p; 545 545 pthread_t uffd_mon; 546 - char c; 546 + char c = '\0'; 547 547 struct uffd_args args = { 0 }; 548 548 args.gopts = gopts; 549 549 ··· 759 759 pthread_t uffd_mon; 760 760 pid_t pid; 761 761 int err; 762 - char c; 762 + char c = '\0'; 763 763 struct uffd_args args = { 0 }; 764 764 args.gopts = gopts; 765 765 ··· 819 819 pthread_t uffd_mon; 820 820 pid_t pid; 821 821 int err; 822 - char c; 822 + char c = '\0'; 823 823 struct uffd_args args = { 0 }; 824 824 args.gopts = gopts; 825 825 ··· 1125 1125 { 1126 1126 unsigned long nr; 1127 1127 pthread_t uffd_mon; 1128 - char c; 1128 + char c = '\0'; 1129 1129 unsigned long long count; 1130 1130 struct uffd_args args = { 0 }; 1131 1131 char *orig_area_src = NULL, *orig_area_dst = NULL;