[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e9c9a9e3-188e-4c6a-b7be-03802e833ef3@collabora.com>
Date: Tue, 23 Apr 2024 13:42:51 +0500
From: Muhammad Usama Anjum <usama.anjum@...labora.com>
To: Kunwu Chan <chentao@...inos.cn>, kunwu.chan@...mail.com,
catalin.marinas@....com, will@...nel.org, shuah@...nel.org
Cc: Muhammad Usama Anjum <usama.anjum@...labora.com>,
linux-arm-kernel@...ts.infradead.org, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] kselftest: arm64: Add a null pointer check
On 4/23/24 1:21 PM, Kunwu Chan wrote:
> There is a 'malloc' call, which can be unsuccessful.
> This patch will add the malloc failure checking
> to avoid possible null dereference and give more information
> about test fail reasons.
LGTM
Reviewed-by: Muhammad Usama Anjum <usama.anjum@...labora.com>
>
> Signed-off-by: Kunwu Chan <chentao@...inos.cn>
> ---
> tools/testing/selftests/arm64/tags/tags_test.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/tools/testing/selftests/arm64/tags/tags_test.c b/tools/testing/selftests/arm64/tags/tags_test.c
> index 5701163460ef..955f87c1170d 100644
> --- a/tools/testing/selftests/arm64/tags/tags_test.c
> +++ b/tools/testing/selftests/arm64/tags/tags_test.c
> @@ -6,6 +6,7 @@
> #include <stdint.h>
> #include <sys/prctl.h>
> #include <sys/utsname.h>
> +#include "../../kselftest.h"
The test isn't conformed to TAP. Maybe the next patch could be to conform
the whole test into TAP, would be easy and straight forward.
>
> #define SHIFT_TAG(tag) ((uint64_t)(tag) << 56)
> #define SET_TAG(ptr, tag) (((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \
> @@ -21,6 +22,9 @@ int main(void)
> if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0) == 0)
> tbi_enabled = 1;
> ptr = (struct utsname *)malloc(sizeof(*ptr));
> + if (!ptr)
> + ksft_exit_fail_msg("Failed to allocate utsname buffer\n");
> +
> if (tbi_enabled)
> tag = 0x42;
> ptr = (struct utsname *)SET_TAG(ptr, tag);
--
BR,
Muhammad Usama Anjum
Powered by blists - more mailing lists