Re: [PATCH bpf-next 1/4] selftests/bpf: Add some null pointer checks

From: Markus Elfring
Date: Wed Apr 24 2024 - 05:36:54 EST



> This patch will add the malloc failure checking


* Please use a corresponding imperative wording for the change description.

* Would you like to add the tag “Fixes” accordingly?



> +++ b/tools/testing/selftests/bpf/test_progs.c
> @@ -582,6 +582,11 @@ int compare_stack_ips(int smap_fd, int amap_fd, int stack_trace_len)
>
> val_buf1 = malloc(stack_trace_len);
> val_buf2 = malloc(stack_trace_len);
> + if (!val_buf1 || !val_buf2) {
> + err = -ENOMEM;
> + goto out;
> + }


How do you think about to reuse “errno” in such error cases?

Regards,
Markus