From patchwork Wed Apr 11 19:45:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10337079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 064406053B for ; Wed, 11 Apr 2018 19:55:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA386281B7 for ; Wed, 11 Apr 2018 19:55:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEA9F2821F; Wed, 11 Apr 2018 19:55:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E97A3281B7 for ; Wed, 11 Apr 2018 19:55:44 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6DF082265A35E; Wed, 11 Apr 2018 12:55:44 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7678122742AA1 for ; Wed, 11 Apr 2018 12:55:42 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2018 12:55:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,437,1517904000"; d="scan'208";a="36484369" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga002.fm.intel.com with ESMTP; 11 Apr 2018 12:55:40 -0700 Subject: [ndctl PATCH] ndctl, read-labels: fix json reference counting From: Dan Williams To: linux-nvdimm@lists.01.org Date: Wed, 11 Apr 2018 12:45:45 -0700 Message-ID: <152347594505.18821.8817528606205630151.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Steve Scargall Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Steve Scargall 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 Signed-off-by: Dan Williams --- ndctl/dimm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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);