From patchwork Tue Jun 30 23:07:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 6698871 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CCDFD9F1C1 for ; Tue, 30 Jun 2015 23:07:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9E3B2062F for ; Tue, 30 Jun 2015 23:07:42 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id A94D72062E for ; Tue, 30 Jun 2015 23:07:41 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6517618282A; Tue, 30 Jun 2015 16:07:41 -0700 (PDT) X-Original-To: linux-nvdimm@ml01.01.org Delivered-To: linux-nvdimm@ml01.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ml01.01.org (Postfix) with ESMTP id A3C28182731 for ; Tue, 30 Jun 2015 16:07:40 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 30 Jun 2015 16:07:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,381,1432623600"; d="scan'208";a="516849986" Received: from orsmsx101.amr.corp.intel.com ([10.22.225.128]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jun 2015 16:07:38 -0700 Received: from orsmsx159.amr.corp.intel.com (10.22.240.24) by ORSMSX101.amr.corp.intel.com (10.22.225.128) with Microsoft SMTP Server (TLS) id 14.3.224.2; Tue, 30 Jun 2015 16:07:38 -0700 Received: from orsmsx107.amr.corp.intel.com ([169.254.1.203]) by ORSMSX159.amr.corp.intel.com ([169.254.11.115]) with mapi id 14.03.0224.002; Tue, 30 Jun 2015 16:07:38 -0700 From: "Williams, Dan J" To: "dan.carpenter@oracle.com" Subject: Re: libnvdimm, nfit, nd_blk: driver for BLK-mode access persistent memory Thread-Topic: libnvdimm, nfit, nd_blk: driver for BLK-mode access persistent memory Thread-Index: AQHQs1wAFucRTekUwEWH5fjDEW/ShZ3GIbiA Date: Tue, 30 Jun 2015 23:07:37 +0000 Message-ID: <1435705653.18090.69.camel@intel.com> References: <20150630174222.GA30796@mwanda> In-Reply-To: <20150630174222.GA30796@mwanda> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.22.254.138] Content-ID: <9382273C7D91B9489F613F54FC953B4A@intel.com> MIME-Version: 1.0 Cc: "linux-acpi@vger.kernel.org" , "linux-nvdimm@ml01.01.org" X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 2015-06-30 at 20:42 +0300, Dan Carpenter wrote: > Hello Ross Zwisler, > > This is a semi-automatic email about new static checker warnings. > > The patch 047fc8a1f9a6: "libnvdimm, nfit, nd_blk: driver for BLK-mode > access persistent memory" from Jun 25, 2015, leads to the following > Smatch complaint: > > drivers/acpi/nfit.c:1224 acpi_nfit_blk_region_enable() > error: we previously assumed 'nfit_mem' could be null (see line 1223) > > drivers/acpi/nfit.c > 1222 nfit_mem = nvdimm_provider_data(nvdimm); > 1223 if (!nfit_mem || !nfit_mem->dcr || !nfit_mem->bdw) { > ^^^^^^^^ > Check. > > 1224 dev_dbg(dev, "%s: missing%s%s%s\n", __func__, > 1225 nfit_mem ? "" : " nfit_mem", > 1226 nfit_mem->dcr ? "" : " dcr", > ^^^^^^^^^^^^^ > Unchecked dereference. Thanks Dan! 8<----- nfit: fix smatch "use after null check" report From: Dan Williams drivers/acpi/nfit.c:1224 acpi_nfit_blk_region_enable() error: we previously assumed 'nfit_mem' could be null (see line 1223) drivers/acpi/nfit.c 1222 nfit_mem = nvdimm_provider_data(nvdimm); 1223 if (!nfit_mem || !nfit_mem->dcr || !nfit_mem->bdw) { ^^^^^^^^ Check. 1224 dev_dbg(dev, "%s: missing%s%s%s\n", __func__, 1225 nfit_mem ? "" : " nfit_mem", 1226 nfit_mem->dcr ? "" : " dcr", ^^^^^^^^^^^^^ Unchecked dereference. Reported-by: Dan Carpenter Acked-by: Ross Zwisler Signed-off-by: Dan Williams --- drivers/acpi/nfit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c index 2161fa178c8d..a20b7c883ca0 100644 --- a/drivers/acpi/nfit.c +++ b/drivers/acpi/nfit.c @@ -1223,8 +1223,8 @@ static int acpi_nfit_blk_region_enable(struct nvdimm_bus *nvdimm_bus, if (!nfit_mem || !nfit_mem->dcr || !nfit_mem->bdw) { dev_dbg(dev, "%s: missing%s%s%s\n", __func__, nfit_mem ? "" : " nfit_mem", - nfit_mem->dcr ? "" : " dcr", - nfit_mem->bdw ? "" : " bdw"); + (nfit_mem && nfit_mem->dcr) ? "" : " dcr", + (nfit_mem && nfit_mem->bdw) ? "" : " bdw"); return -ENXIO; }