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

selftests/memfd/memfd_test: fix possible NULL pointer dereference

If `name' is NULL, a NULL pointer may be accessed in printf.

Link: https://lkml.kernel.org/r/20250114032115.58638-1-liuye@kylinos.cn
Signed-off-by: liuye <liuye@kylinos.cn>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: "Isaac J. Manjarres" <isaacmanjarres@google.com>
Cc: Jeff Xu <jeffxu@google.com>
Cc: Saurav Shah <sauravshah.31@gmail.com>
Cc: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

liuye and committed by
Andrew Morton
73519ded d94d23fd

+1 -1
+1 -1
tools/testing/selftests/memfd/memfd_test.c
··· 171 171 r = sys_memfd_create(name, flags); 172 172 if (r >= 0) { 173 173 printf("memfd_create(\"%s\", %u) succeeded, but failure expected\n", 174 - name, flags); 174 + name ? name : "NULL", flags); 175 175 close(r); 176 176 abort(); 177 177 }