mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nvdimm: ndtest: remove redundant NULL check before vfree()
@ 2026-07-03 13:55 mdshahid03
  2026-07-06 22:33 ` Dave Jiang
  2026-07-15  0:01 ` Alison Schofield
  0 siblings, 2 replies; 3+ messages in thread
From: mdshahid03 @ 2026-07-03 13:55 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang, Alison Schofield, Ira Weiny
  Cc: nvdimm, linux-kernel, Mohammad Shahid

From: Mohammad Shahid <mdshahid03@gmail.com>

vfree() safely handles NULL pointers, so the explicit NULL check
before calling vfree() is unnecessary.

This issue was reported by ifnullfree.cocci.

Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
---
 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 8e3b6be53839..2051ad5d4882 100644
--- a/tools/testing/nvdimm/test/ndtest.c
+++ b/tools/testing/nvdimm/test/ndtest.c
@@ -376,8 +376,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;
-- 
2.43.0


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

* Re: [PATCH] nvdimm: ndtest: remove redundant NULL check before vfree()
  2026-07-03 13:55 [PATCH] nvdimm: ndtest: remove redundant NULL check before vfree() mdshahid03
@ 2026-07-06 22:33 ` Dave Jiang
  2026-07-15  0:01 ` Alison Schofield
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2026-07-06 22:33 UTC (permalink / raw)
  To: mdshahid03, Dan Williams, Vishal Verma, Alison Schofield, Ira Weiny
  Cc: nvdimm, linux-kernel



On 7/3/26 6:55 AM, mdshahid03@gmail.com wrote:
> From: Mohammad Shahid <mdshahid03@gmail.com>
> 
> vfree() safely handles NULL pointers, so the explicit NULL check
> before calling vfree() is unnecessary.
> 
> This issue was reported by ifnullfree.cocci.
> 
> Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
>  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 8e3b6be53839..2051ad5d4882 100644
> --- a/tools/testing/nvdimm/test/ndtest.c
> +++ b/tools/testing/nvdimm/test/ndtest.c
> @@ -376,8 +376,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;


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

* Re: [PATCH] nvdimm: ndtest: remove redundant NULL check before vfree()
  2026-07-03 13:55 [PATCH] nvdimm: ndtest: remove redundant NULL check before vfree() mdshahid03
  2026-07-06 22:33 ` Dave Jiang
@ 2026-07-15  0:01 ` Alison Schofield
  1 sibling, 0 replies; 3+ messages in thread
From: Alison Schofield @ 2026-07-15  0:01 UTC (permalink / raw)
  To: mdshahid03
  Cc: Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny, nvdimm, linux-kernel

On Fri, Jul 03, 2026 at 07:25:13PM +0530, mdshahid03@gmail.com wrote:
> From: Mohammad Shahid <mdshahid03@gmail.com>
> 
> vfree() safely handles NULL pointers, so the explicit NULL check
> before calling vfree() is unnecessary.
> 
> This issue was reported by ifnullfree.cocci.
> 
> Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>

Applied to libnvdimm-for-next:
https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/

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

end of thread, other threads:[~2026-07-15  0:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-03 13:55 [PATCH] nvdimm: ndtest: remove redundant NULL check before vfree() mdshahid03
2026-07-06 22:33 ` Dave Jiang
2026-07-15  0:01 ` Alison Schofield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox