lkml.org 
[lkml]   [2020]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] bpf_stats_record: Add null check after malloc
From
Date
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();
>

\
 
 \ /
  Last update: 2020-06-08 16:17    [W:0.030 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site