Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4414937ybg; Mon, 8 Jun 2020 07:20:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYwQzZjUfoAz0gcj/gJBfFqwZE9/Lb4F0LlLMZCXtgIaDiDikM9cNZwkkDY7fjwUlH3OVS X-Received: by 2002:a50:fc04:: with SMTP id i4mr21816365edr.117.1591626050332; Mon, 08 Jun 2020 07:20:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591626050; cv=none; d=google.com; s=arc-20160816; b=lmnKuTMg47F4lwO8RriY9ypVzZYoxx2budm9sCecJNJe2yp3a9ETgZwF6g6SUagjN1 YHzwUSLwy9nR523dmcFozymApX+tnXGP7tPNvNiN260ATLUwSfLGx+MLnuTJ6d7U4VXi 9LDEC6izCVZXl0X9sNWDppaG3ZpW0G+xMJR+ZwflOJ5vFguvl0vY68h4TYBHCoSMzDJy lctyT+jsKBogXxaBw3EdeBQr8VKa7CqH88uvInc3ju4/zShKB79QSZwdoNI9hyWxGoaA Q65BHciUuOQk0HDwsdDua8pQnbrhZrdst0QsSaosl6EKRsFopkYMCHWtrI5T2ZYJELTu ZR9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=TToT3GovVQzdVY1hRJpm8+LWsI3U4mhrv8axYKSWQcI=; b=gvnvJKQ9CpE3Paedc6vyJKelRKi1xAQL5mKEhUPrcW8lttz61Nb//0vfVd6v1243qq iX/uypgesZ9KNc3N6WIjgYa92eTDofJByYxlwCnFgrkXtdcbyidc/i8gE1pqI+hWIMM+ X7wfHVjPi1REVBOPahbiH+xaSp6HRj3fclHx6OvHyx/tHyQMnDe2MSSi+c+v6zTEJyzQ r7o9A/4T/7N65r7sMCXbA74goi9ALmSJ7I3M+LksJAgjF7BSkqfsj5yY0bVhp0hgYGXT 5sWl0EEs2ThX6g0hC4D42TLroMZpWkz01QHim2mqycB+g5VTeTPn5VctUM22V3EcLKfK 0P6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k15si1975222edq.127.2020.06.08.07.19.57; Mon, 08 Jun 2020 07:20:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729949AbgFHOP6 (ORCPT + 99 others); Mon, 8 Jun 2020 10:15:58 -0400 Received: from www62.your-server.de ([213.133.104.62]:38058 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbgFHOP6 (ORCPT ); Mon, 8 Jun 2020 10:15:58 -0400 Received: from sslproxy06.your-server.de ([78.46.172.3]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1jiIYy-0006tM-It; Mon, 08 Jun 2020 16:15:44 +0200 Received: from [178.196.57.75] (helo=pc-9.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jiIYy-000EuU-4N; Mon, 08 Jun 2020 16:15:44 +0200 Subject: Re: [PATCH] bpf_stats_record: Add null check after malloc To: gaurav singh , ast@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, andriin@fb.com, john.fastabend@gmail.com, kpsingh@chromium.org, davem@davemloft.net, kuba@kernel.org, awk@kernel.org Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Daniel Borkmann Message-ID: Date: Mon, 8 Jun 2020 16:15:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.3/25837/Mon Jun 8 14:50:11 2020) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Date: Sat, 6 Jun 2020 19:42:53 -0400 > Subject: [PATCH] bpf_stats_record: Add null check after malloc > > Signed-off-by: Gaurav Singh > --- > 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(); >