From patchwork Thu Jun 23 19:59:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Moyer X-Patchwork-Id: 9195921 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 B1B82608A0 for ; Thu, 23 Jun 2016 19:59:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A337028472 for ; Thu, 23 Jun 2016 19:59:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97DFC28474; Thu, 23 Jun 2016 19:59:55 +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=-1.9 required=2.0 tests=BAYES_00, 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 6BA5328472 for ; Thu, 23 Jun 2016 19:59:55 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 08B8F1A1E12; Thu, 23 Jun 2016 13:00:26 -0700 (PDT) X-Original-To: linux-nvdimm@ml01.01.org Delivered-To: linux-nvdimm@ml01.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 E82A71A1E0F for ; Thu, 23 Jun 2016 13:00:24 -0700 (PDT) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06A7B63146; Thu, 23 Jun 2016 19:59:53 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5NJxqXu027421; Thu, 23 Jun 2016 15:59:52 -0400 Received: by segfault.boston.devel.redhat.com (Postfix, from userid 3734) id 3CCC1303FD64F; Thu, 23 Jun 2016 15:59:52 -0400 (EDT) From: Jeff Moyer To: dan.j.williams@intel.com Subject: [PATCH 1/3] util_namespace_to_json: fix potential null pointer dereference Date: Thu, 23 Jun 2016 15:59:48 -0400 Message-Id: <20160623195950.30968-2-jmoyer@redhat.com> In-Reply-To: <20160623195950.30968-1-jmoyer@redhat.com> References: <20160623195950.30968-1-jmoyer@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 23 Jun 2016 19:59:53 +0000 (UTC) X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nvdimm@ml01.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Coverity pointed out that "dax" could be NULL, and it goes unchecked. Signed-off-by: Jeff Moyer --- ndctl/util/json.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ndctl/util/json.c b/ndctl/util/json.c index d144039..92e50fa 100644 --- a/ndctl/util/json.c +++ b/ndctl/util/json.c @@ -133,6 +133,8 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns) jobj = json_object_new_string("memory"); break; case NDCTL_NS_MODE_DAX: + if (!dax) + goto err; size = ndctl_dax_get_size(dax); jobj = json_object_new_string("dax"); break;