mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: liuye <liuye@kylinos.cn>
To: shuah@kernel.org
Cc: akpm@linux-foundation.org, jeffxu@google.com,
	isaacmanjarres@google.com, lorenzo.stoakes@oracle.com,
	gthelen@google.com, sauravshah.31@gmail.com,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	liuye <liuye@kylinos.cn>
Subject: [PATCH] selftests/memfd/memfd_test: Fix possible NULL pointer dereference
Date: Tue, 14 Jan 2025 11:21:15 +0800	[thread overview]
Message-ID: <20250114032115.58638-1-liuye@kylinos.cn> (raw)

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

Signed-off-by: liuye <liuye@kylinos.cn>
---
 tools/testing/selftests/memfd/memfd_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index c0c53451a16d..5b993924cc3f 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -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();
 	}
-- 
2.25.1


             reply	other threads:[~2025-01-14  3:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14  3:21 liuye [this message]
2025-01-14  4:13 ` Andrew Morton
2025-01-14 11:10 ` Lorenzo Stoakes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250114032115.58638-1-liuye@kylinos.cn \
    --to=liuye@kylinos.cn \
    --cc=akpm@linux-foundation.org \
    --cc=gthelen@google.com \
    --cc=isaacmanjarres@google.com \
    --cc=jeffxu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=sauravshah.31@gmail.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®