nvdimm: nfit: remove redundant NULL check before vfree()
PATCH 1/1 nvdimm: nfit: remove redundant NULL check before vfree()
From: Mohammad Shahid <[email protected]>
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 <[email protected]>
--- tools/testing/nvdimm/test/nfit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/nvdimm/test/nfit.c +1 -2
@@ -1644,8 +1644,7 @@ 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 ; }
Signature · 1 line
2.43.0
Quoted 8 lines · On 7/3/26 7:48 AM, [email protected] wrote:
From: Mohammad Shahid <[email protected]>
vfree()safely handles NULL pointers, so the explicit NULL check before callingvfree()is unnecessary.This issue was reported by
ifnullfree.cocci.Signed-off-by Mohammad Shahid <[email protected]>
Reviewed-by Dave Jiang <[email protected]>
Quoted 18 lines
--- tools/testing/nvdimm/test/nfit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)tools/testing/nvdimm/test/nfit.c +1
-2@@ -1644,8 +1644,7 @@ 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 ; }
Quoted 8 lines · On Fri, Jul 03, 2026 at 08:18:51PM +0530, [email protected] wrote:
From: Mohammad Shahid <[email protected]>
vfree()safely handles NULL pointers, so the explicit NULL check before callingvfree()is unnecessary.This issue was reported by
ifnullfree.cocci.Signed-off-by Mohammad Shahid <[email protected]>
Applied to libnvdimm-for-next:
https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git/