]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
selftests/memfd/memfd_test: fix possible NULL pointer dereference
authorliuye <liuye@kylinos.cn>
Tue, 14 Jan 2025 03:21:15 +0000 (11:21 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 26 Jan 2025 04:22:44 +0000 (20:22 -0800)
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>
tools/testing/selftests/memfd/memfd_test.c

index c0c53451a16dc1197b044f69d372a54d36730964..5b993924cc3f5bc008bd33e72eb78a034793e6f7 100644 (file)
@@ -171,7 +171,7 @@ static void mfd_fail_new(const char *name, unsigned int flags)
        r = sys_memfd_create(name, flags);
        if (r >= 0) {
                printf("memfd_create(\"%s\", %u) succeeded, but failure expected\n",
-                      name, flags);
+                      name ? name : "NULL", flags);
                close(r);
                abort();
        }