diff mbox

[ndctl] ndctl, check-namespace: fix resource leak

Message ID 149850317639.1029.4272990186528265578.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit f81ccf1cc4a8
Headers show

Commit Message

Dan Williams June 26, 2017, 6:52 p.m. UTC
Static analysis points out that we leak 'bttc' in namespace_check().

Cc: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/check.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/ndctl/check.c b/ndctl/check.c
index 3775c2ed4a3a..2d913cf5a4c2 100644
--- a/ndctl/check.c
+++ b/ndctl/check.c
@@ -898,7 +898,8 @@  int namespace_check(struct ndctl_namespace *ndns, struct check_opts *opts)
 
 	if (sigaction(SIGBUS, &act, 0)) {
 		err(bttc, "Unable to set sigaction\n");
-		return -errno;
+		rc = -errno;
+		goto out_bttc;
 	}
 
 	bttc->opts = opts;
@@ -912,7 +913,7 @@  int namespace_check(struct ndctl_namespace *ndns, struct check_opts *opts)
 		if (opts->force) {
 			rc = ndctl_namespace_disable_safe(ndns);
 			if (rc)
-				return rc;
+				goto out_bttc;
 			disabled_flag = 1;
 		} else {
 			err(bttc, "%s: check aborted, namespace online\n",