linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/testing/nvdimm: NULL check before vfree() is not needed
@ 2021-06-25  7:27 13145886936
  2021-06-25 17:37 ` Alison Schofield
  0 siblings, 1 reply; 2+ messages in thread
From: 13145886936 @ 2021-06-25  7:27 UTC (permalink / raw)
  To: dan.j.williams, vishal.l.verma, dave.jiang, ira.weiny
  Cc: nvdimm, linux-kernel, gushengxian

From: gushengxian <gushengxian@yulong.com>

NULL check before vfree() is not needed.

Signed-off-by: gushengxian <gushengxian@yulong.com>
---
 tools/testing/nvdimm/test/nfit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index 54f367cbadae..cb86f0cbb11c 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -1641,8 +1641,8 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma,
  err:
 	if (*dma && size >= DIMM_SIZE)
 		gen_pool_free(nfit_pool, *dma, size);
-	if (buf)
-		vfree(buf);
+
+	vfree(buf);
 	kfree(nfit_res);
 	return NULL;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tools/testing/nvdimm: NULL check before vfree() is not needed
  2021-06-25  7:27 [PATCH] tools/testing/nvdimm: NULL check before vfree() is not needed 13145886936
@ 2021-06-25 17:37 ` Alison Schofield
  0 siblings, 0 replies; 2+ messages in thread
From: Alison Schofield @ 2021-06-25 17:37 UTC (permalink / raw)
  To: 13145886936
  Cc: dan.j.williams, vishal.l.verma, dave.jiang, ira.weiny, nvdimm,
	linux-kernel, gushengxian


Hi Gushengxian,

The code change looks good.  A couple of cleanups noted below...
(same feedback on next patch too)


On Fri, Jun 25, 2021 at 12:27:00AM -0700, 13145886936@163.com wrote:
> From: gushengxian <gushengxian@yulong.com>
> 
> NULL check before vfree() is not needed.

The commit message needs to say what was done, not the why.
Example: "[PATCH] tools/testing/nvdimm: Remove NULL test before vfree"

Then, the commit log explains why this should be done.
Example: "This NULL test is redundant since vfree() checks for NULL."

Coccinelle reports this vfree() case. If you did use Coccinelle
to find it, please mention that in the commit log.
Example: "Reported by Coccinelle."

> 
> Signed-off-by: gushengxian <gushengxian@yulong.com>

The email addresses don't match (13145886936@163.com,
gushengxian@yulong.com) and it's not clear that you are using your
full, legal name in the 'name line.

You can find more info on this feedback at:
https://kernelnewbies.org/FirstKernelPatch
https://www.kernel.org/doc/html/latest/process/submitting-patches.html

Alison

> ---
>  tools/testing/nvdimm/test/nfit.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
> index 54f367cbadae..cb86f0cbb11c 100644
> --- a/tools/testing/nvdimm/test/nfit.c
> +++ b/tools/testing/nvdimm/test/nfit.c
> @@ -1641,8 +1641,8 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma,
>   err:
>  	if (*dma && size >= DIMM_SIZE)
>  		gen_pool_free(nfit_pool, *dma, size);
> -	if (buf)
> -		vfree(buf);
> +
> +	vfree(buf);
>  	kfree(nfit_res);
>  	return NULL;
>  }
> -- 
> 2.25.1
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-25 17:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-25  7:27 [PATCH] tools/testing/nvdimm: NULL check before vfree() is not needed 13145886936
2021-06-25 17:37 ` Alison Schofield

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).