Re: [PATCH bpf-next v2 4/4] selftests/bpf: Add a null pointer check for the serial_test_tp_attach_query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/10/24 2:58 PM, kunwu.chan@xxxxxxxxx wrote:
> From: Kunwu Chan <chentao@xxxxxxxxxx>
> 
> There is a 'malloc' call, which can be unsuccessful.
> Add the malloc failure checking to avoid possible null
> dereference.
> 
> Signed-off-by: Kunwu Chan <chentao@xxxxxxxxxx>
> Suggested-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
> ---
> Changes in v2:
> 	- Use ASSERT* instead of CHECK
> 	- Add suggested-by tag
> ---
>  tools/testing/selftests/bpf/prog_tests/tp_attach_query.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c b/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
> index 655d69f0ff0b..a5ebfc172ad8 100644
> --- a/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
> +++ b/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
> @@ -39,6 +39,9 @@ void serial_test_tp_attach_query(void)
>  	attr.wakeup_events = 1;
>  
>  	query = malloc(sizeof(*query) + sizeof(__u32) * num_progs);
> +	if (!ASSERT_OK_PTR(query, "malloc"))
> +		return;
> +
LGTM
Reviewed-by: Muhammad Usama Anjum <usama.anjum@xxxxxxxxxxxxx>

>  	for (i = 0; i < num_progs; i++) {
>  		err = bpf_prog_test_load(file, BPF_PROG_TYPE_TRACEPOINT, &obj[i],
>  				    &prog_fd[i]);

-- 
BR,
Muhammad Usama Anjum




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux