diff mbox

[ndctl] ndctl, read-labels: fix json reference counting

Message ID 152347594505.18821.8817528606205630151.stgit@dwillia2-desk3.amr.corp.intel.com
State Accepted
Commit dd635fb
Headers show

Commit Message

Dan Williams April 11, 2018, 7:45 p.m. UTC
From: Steve Scargall <steve.scargall@intel.com>

Current versions of the json-c library abort when decrementing an object
reference past 0. Given that util_display_json_array() drops the
reference to the passed in object we do not need to drop the reference
in dimm_action(). This fixes failures with the following signature:

    $ ndctl read-labels nmem0 nmem1 -j
    ...
    ndctl: json_object.c:159: json_object_put: Assertion `jso->_ref_count > 0' failed.
    Aborted (core dumped)

Signed-off-by: Steve Scargall <steve.scargall@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/dimm.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox

Patch

diff --git a/ndctl/dimm.c b/ndctl/dimm.c
index f51f34bb28b6..1c168997105e 100644
--- a/ndctl/dimm.c
+++ b/ndctl/dimm.c
@@ -1080,11 +1080,9 @@  static int dimm_action(int argc, const char **argv, void *ctx,
 			rc = action(single, &actx);
 	}
 
-	if (actx.jdimms) {
+	if (actx.jdimms)
 		util_display_json_array(actx.f_out, actx.jdimms,
 				JSON_C_TO_STRING_PRETTY);
-		json_object_put(actx.jdimms);
-	}
 
 	if (actx.f_out != stdout)
 		fclose(actx.f_out);