Static analysis reports that we can potentially dereference a null
pointer in the above function. Fix by checking the return value from the
allocation.

Cc: Dan Williams <[email protected]>
Fixes: 8229da8d73a3 ("ndctl: ship the unit test as 'ndctl test'")
Signed-off-by: Vishal Verma <[email protected]>
---
 ndctl/test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ndctl/test.c b/ndctl/test.c
index 285594f..25ec61c 100644
--- a/ndctl/test.c
+++ b/ndctl/test.c
@@ -55,6 +55,8 @@ int cmd_test(int argc, const char **argv, void *ctx)
                test = ndctl_test_new(UINT_MAX);
        else
                test = ndctl_test_new(0);
+       if (!test)
+               return EXIT_FAILURE;
 
        rc = test_libndctl(loglevel, test, ctx);
        fprintf(stderr, "test-libndctl: %s\n", result(rc));
-- 
2.14.4

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to