[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <51b0775f-0268-45f1-ba81-585d1eff9a0f@lucifer.local>
Date: Tue, 14 Jan 2025 11:10:26 +0000
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: liuye <liuye@...inos.cn>
Cc: shuah@...nel.org, akpm@...ux-foundation.org, jeffxu@...gle.com,
isaacmanjarres@...gle.com, gthelen@...gle.com, sauravshah.31@...il.com,
linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] selftests/memfd/memfd_test: Fix possible NULL pointer
dereference
On Tue, Jan 14, 2025 at 11:21:15AM +0800, liuye wrote:
> If name is NULL, a NULL pointer may be accessed in printf.
>
> Signed-off-by: liuye <liuye@...inos.cn>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
> ---
> 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);
Damn, I was going to say 'oh hey we never pass NULL' but in test_create() we
explicitly... do. Good spot!
> close(r);
> abort();
> }
> --
> 2.25.1
>
Powered by blists - more mailing lists