Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3724032pxf; Mon, 22 Mar 2021 13:24:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFA9XcMf5ceH2m2tOCHCpdoa4XhD+urKi9h/uRjkdj3V/RmTM3bMWuRempF8II9KiQNRN1 X-Received: by 2002:a17:907:1614:: with SMTP id hb20mr1526390ejc.77.1616444640879; Mon, 22 Mar 2021 13:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616444640; cv=none; d=google.com; s=arc-20160816; b=NRenGIUDieg++X6hOzDhGUbBJYqEtupTSXIKdvHPPfiPVKP8RuvNX5cZsUga8wQC5m F6JKpzvSdXAN/4cccp2Y22lLTD0exCj5+Xn77/U7eT5WsTp8FS5FJUdOakGch6xezmj2 0kxdbGz0nKe6tcRwNtIqPNhDuLveG6unLyvTGkByr4FBZCQemoSskK4EJxrrJUN6lqEp 6PDqkz9M5b+3oxSG1dqjRALDvSrsIsNZv0DhJRjMSuxfh3InQ4xVrYJZJcvWiiBKbOG7 eiYc5WDT8FPt9xY/o6VehUB7HxPwPaD70SC0nA3gT+n7SwkEib9IhPQjjlojbXnJdbZr cFtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=BcQeoaacs4/GEP+9c+Ox1fh2vh/FP3o/zdKXLx6vtcQ=; b=NzyHZs3XjtHgQQ9mFmCV0L1hH6oJMwMl7D48O+SNee/ZcoDqyaXKo67l2+L2Cz0lM6 jmLrDlNipU5BCY60VJOwdwgnXZUwyvBsS5WtGNvbqmASSwS+kSIDqqcL+h0YuhaZE5S/ ccJvx6pzZNktxBDdwOMiYRzS1GalC33HCzg9zTBNuRqhDSFOysfP1FGsxjxwqoAZcDT5 g4+Mm2TIP0oZQOuMc3963NxEL8xm8rwft8BmBlY6pFgBFUizKAe7HdNaD+6jmappm4d5 K56ohxR4VBqRQpqsXU1xsjKey9HA2HJQauwiMV1zNBVIrkV/mwZD8fjGfUIZ78EoVV1M FSBQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si12113358edc.63.2021.03.22.13.23.38; Mon, 22 Mar 2021 13:24:00 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232072AbhCVUUs (ORCPT + 99 others); Mon, 22 Mar 2021 16:20:48 -0400 Received: from mga17.intel.com ([192.55.52.151]:45108 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231303AbhCVUUd (ORCPT ); Mon, 22 Mar 2021 16:20:33 -0400 IronPort-SDR: NHWswus/u7VW0hD8+F5rYXlkLoF2V88IgeBdbGGYxj4oQJW2hN00UKqZYU+XJdh3u2XaECx9Ac tQwZLrMGE5JQ== X-IronPort-AV: E=McAfee;i="6000,8403,9931"; a="170303766" X-IronPort-AV: E=Sophos;i="5.81,269,1610438400"; d="scan'208";a="170303766" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2021 13:20:29 -0700 IronPort-SDR: 6C5Nj2ZylD2XYwjKPnqLs+KXDFNekRQ8zw3ZrFeke9h5NrEQaKMX3hCkNwjXiyd7VrIOp9IDz4 ERhY2Shm5WlA== X-IronPort-AV: E=Sophos;i="5.81,269,1610438400"; d="scan'208";a="414632436" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2021 13:20:29 -0700 Date: Mon, 22 Mar 2021 13:20:29 -0700 From: Ira Weiny To: Jiapeng Chong Cc: dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, Santosh Sivaraj Subject: Re: [PATCH] ndtest: Remove redundant NULL check Message-ID: <20210322202029.GP3014244@iweiny-DESK2.sc.intel.com> References: <1616407240-114077-1-git-send-email-jiapeng.chong@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1616407240-114077-1-git-send-email-jiapeng.chong@linux.alibaba.com> User-Agent: Mutt/1.11.1 (2018-12-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 22, 2021 at 06:00:40PM +0800, Jiapeng Chong wrote: > Fix the following coccicheck warnings: > > ./tools/testing/nvdimm/test/ndtest.c:491:2-7: WARNING: NULL check before > some freeing functions is not needed. I don't think there is anything wrong with this patch specifically but why is buf not checked for null after the vmalloc? It seems to me that if size >= DIMM_SIZE and the vmalloc fails the gen pool allocation is going to be leaked. Ira > > Reported-by: Abaci Robot > Signed-off-by: Jiapeng Chong > --- > tools/testing/nvdimm/test/ndtest.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/tools/testing/nvdimm/test/ndtest.c b/tools/testing/nvdimm/test/ndtest.c > index 6862915..98b4a43 100644 > --- a/tools/testing/nvdimm/test/ndtest.c > +++ b/tools/testing/nvdimm/test/ndtest.c > @@ -487,8 +487,7 @@ static void *ndtest_alloc_resource(struct ndtest_priv *p, size_t size, > buf_err: > if (__dma && size >= DIMM_SIZE) > gen_pool_free(ndtest_pool, __dma, size); > - if (buf) > - vfree(buf); > + vfree(buf); > kfree(res); > > return NULL; > -- > 1.8.3.1 >