* Re: [PATCH] bpf_stats_record: Add null check after malloc
[not found] <CAFAFadBRhEwuFCa-kMNPgRF8+gHycVvWcGfvbX0Pmjb6wt4SZA@mail.gmail.com>
@ 2020-06-08 14:15 ` Daniel Borkmann
0 siblings, 0 replies; only message in thread
From: Daniel Borkmann @ 2020-06-08 14:15 UTC (permalink / raw)
To: gaurav singh, ast, kafai, songliubraving, yhs, andriin,
john.fastabend, kpsingh, davem, kuba, awk
Cc: netdev, bpf, linux-kernel
On 6/7/20 1:46 AM, gaurav singh wrote:
> Hi,
>
> The memset call is made right after malloc call. To fix this, add the null
> check right after malloc and then do memset.
>
> Please find the patch below.
>
> Thanks and regards,
> Gaurav.
Hello Gaurav, your patch is whitespace damaged. Please try and resubmit with git-send-email.
> From 8083a35f85c6047f0377883ed66ae147f85fd3a9 Mon Sep 17 00:00:00 2001
> From: Gaurav Singh <gaurav1086@gmail.com>
> Date: Sat, 6 Jun 2020 19:42:53 -0400
> Subject: [PATCH] bpf_stats_record: Add null check after malloc
>
> Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
> ---
> samples/bpf/xdp_rxq_info_user.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/samples/bpf/xdp_rxq_info_user.c
> b/samples/bpf/xdp_rxq_info_user.c
> index 4fe47502ebed..c44b9a844066 100644
> --- a/samples/bpf/xdp_rxq_info_user.c
> +++ b/samples/bpf/xdp_rxq_info_user.c
> @@ -233,11 +233,11 @@ static struct stats_record *alloc_stats_record(void)
> int i;
>
> rec = malloc(sizeof(*rec));
> - memset(rec, 0, sizeof(*rec));
> if (!rec) {
> fprintf(stderr, "Mem alloc error\n");
> exit(EXIT_FAIL_MEM);
> }
> + memset(rec, 0, sizeof(*rec));
> rec->rxq = alloc_record_per_rxq();
> for (i = 0; i < nr_rxqs; i++)
> rec->rxq[i].cpu = alloc_record_per_cpu();
>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-08 14:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAFAFadBRhEwuFCa-kMNPgRF8+gHycVvWcGfvbX0Pmjb6wt4SZA@mail.gmail.com>
2020-06-08 14:15 ` [PATCH] bpf_stats_record: Add null check after malloc Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).