ndtest: Remove redundant NULL check
PATCH 1/1 ndtest: Remove redundant NULL check
Fix the following coccicheck warnings:
./tools/testing/nvdimm/test/ndtest.c:491:2-7: WARNING: NULL check before some freeing functions is not needed.
--- tools/testing/nvdimm/test/ndtest.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/nvdimm/test/ndtest.c +1 -2
@@ -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 ;
Signature · 4 lines
1.8.3.1 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Quoted 4 lines · Jiapeng Chong
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
Quoted 24 lines
Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>--- tools/testing/nvdimm/test/ndtest.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)tools/testing/nvdimm/test/ndtest.c +1
-2@@ -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 ;Signature · 1 line
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Hi Ira,
Quoted 12 lines · Ira Weiny
Quoted 4 lines · Jiapeng Chong
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_SIZEand the vmalloc fails the gen pool allocation is going to be leaked.
If vmalloc fails, gen_pool_free will get called through ndtest_release_resource, registered with devm_action. But we will still need to check for vmalloc fail.
I will fix that when I send my inject-error support for the driver.
Thanks,
Santosh
Quoted 22 lines
Ira
Quoted 20 lines
Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>--- tools/testing/nvdimm/test/ndtest.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)tools/testing/nvdimm/test/ndtest.c +1
-2@@ -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);
Quoted 4 lines
Quoted 4 lines
tools/testing/nvdimm/test/ndtest.c +0
-0return NULL ;Signature · 1 line
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]