bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gaurav Singh <gaurav1086@gmail.com>
To: gaurav1086@gmail.com, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	netdev@vger.kernel.org (open list:BPF (Safe dynamic programs and
	tools)),
	bpf@vger.kernel.org (open list:BPF (Safe dynamic programs and
	tools)), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] bpf: alloc_record_per_cpu Add null check after malloc
Date: Tue,  9 Jun 2020 07:38:39 -0400	[thread overview]
Message-ID: <20200609113839.9628-2-gaurav1086@gmail.com> (raw)
In-Reply-To: <20200609113839.9628-1-gaurav1086@gmail.com>

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..490b07b7df78 100644
--- a/samples/bpf/xdp_rxq_info_user.c
+++ b/samples/bpf/xdp_rxq_info_user.c
@@ -202,11 +202,11 @@ static struct datarec *alloc_record_per_cpu(void)
 
 	size = sizeof(struct datarec) * nr_cpus;
 	array = malloc(size);
-	memset(array, 0, size);
 	if (!array) {
 		fprintf(stderr, "Mem alloc error (nr_cpus:%u)\n", nr_cpus);
 		exit(EXIT_FAIL_MEM);
 	}
+	memset(array, 0, size);
 	return array;
 }
 
-- 
2.17.1


  reply	other threads:[~2020-06-09 11:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-09 11:38 Gaurav Singh
2020-06-09 11:38 ` Gaurav Singh [this message]
2020-06-09 11:55   ` [PATCH] bpf: alloc_record_per_cpu Add null check after malloc Greg KH
2020-06-09 11:54 ` your mail Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2020-06-09 12:08 [PATCH] bpf: alloc_record_per_cpu Add null check after malloc Gaurav Singh
2020-06-09 12:23 ` Jesper Dangaard Brouer
     [not found] <CAFAFadDVe1Au2eJ8ho_cK1riwf9FDaGck3o+VEcKpqRgO5qXdA@mail.gmail.com>
2020-06-09  6:50 ` Jesper Dangaard Brouer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200609113839.9628-2-gaurav1086@gmail.com \
    --to=gaurav1086@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).