Static analysis reports that we leak ndctl_cmd in the above function.
Fix by adding the cmd_unref to the exit path in the
__check_smart_threshold macro.

Cc: Dan Williams <[email protected]>
Fixes: 7fa8a6af6917 ("test, libndctl: fix SMART test assumptions")
Signed-off-by: Vishal Verma <[email protected]>
---
 test/libndctl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/libndctl.c b/test/libndctl.c
index edff0af..e36c1fb 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -2250,6 +2250,7 @@ static int check_smart(struct ndctl_bus *bus, struct 
ndctl_dimm *dimm,
                                ndctl_dimm_get_handle(dimm), \
                                smart_t_data.field, \
                                ndctl_cmd_smart_threshold_get_##field(cmd)); \
+               ndctl_cmd_unref(cmd_set); \
                ndctl_cmd_unref(cmd); \
                return -ENXIO; \
        } \
-- 
2.14.4

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

Reply via email to