[ndctl PATCH 5/5] ndctl, test: fix a resource leak in check_smart_threshold

Vishal Verma
2018-08-10T22:56:32Z

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 <dan.j.williams@intel.com>
Fixes: 7fa8a6af6917 ("test, libndctl: fix SMART test assumptions")
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
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; \
} \