Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp299390imm; Thu, 5 Jul 2018 00:04:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeVqqiZrbXiu2t4oTsy2RdIWFSTDwYBoJFo8bXIvy8NHaTLyyFmuaH9odYQeNXmmtuZXmHS X-Received: by 2002:a63:551e:: with SMTP id j30-v6mr4323464pgb.92.1530774240030; Thu, 05 Jul 2018 00:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530774240; cv=none; d=google.com; s=arc-20160816; b=zdzZOX6IuXXvMp/rBmvgYGEGgXJnf9nMAyBDILkMaFKmjWTwWBO61IHln/szmGy/AQ 0ZcHANQvpzoM7hFbuFzgDRk50iInjnyaHKKiAP8gWkP+lMXjarzX7AggRxzpKcEtlJTB EaJqy4i7MCqynFK9zKuE7ID0RoC+BmW95I6ckgu7Mw94szZunRItWLriOMuHAc6PAha7 8mo+t9b1AmkpkthQOzPIFLYhU3pbBsOI0/fBp0/7UN/eQrTu1wsjUEgnRZB5KB0Ydibd +kLVeqVbZ/2YsGQxlTipUab5RmnwqyDjTUgOkcxyGU4oAVN6eWfld5RH9ev/+ZzyggUp bR9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:arc-authentication-results; bh=CoSC/3Fi8L6h7NQhmevDzSKfrrXp6p2PHCeZ3XAO6BY=; b=Lz0oRpcojhusDHpKBuaslRP9DNwN2upVvPZCEc07rpQizQRDH39AFi4LWJD2OW/a9k r7/IQnDqrcX2/cq2skXME8/YiRXaiglQIg2v9jKghmFoRvW8Py4Lx788S2ncHcQsJ8bO 1vBbRdBV2zS0UqiHTC5tuIHDAQhj1kkrSGdvGcpCWiEirx7W82TGC7QqjlP5YZLsdx17 5gvS4A7/h2zHUPatbIW35fHbZCfnKeJwA5t3wOj90lwtIO1cAWR6GNj7GE/P5HARB1UL YZC+2Ni4JojtyZn2wScL5VcnNw+V5vIyacdR6h4/W2h8OoL43dw8qdRtluaWpsXBfoiS RWcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j91-v6si5250088pld.402.2018.07.05.00.03.45; Thu, 05 Jul 2018 00:03:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753773AbeGEHBa (ORCPT + 99 others); Thu, 5 Jul 2018 03:01:30 -0400 Received: from mga04.intel.com ([192.55.52.120]:44087 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752773AbeGEG7c (ORCPT ); Thu, 5 Jul 2018 02:59:32 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 23:59:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,311,1526367600"; d="scan'208";a="62403642" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by FMSMGA003.fm.intel.com with ESMTP; 04 Jul 2018 23:59:32 -0700 Subject: [PATCH 06/13] nvdimm/pmem: check the validity of the pointer pfn From: Dan Williams To: akpm@linux-foundation.org Cc: Huaisheng Ye , Jan Kara , vishal.l.verma@intel.com, hch@lst.de, linux-nvdimm@lists.01.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Wed, 04 Jul 2018 23:49:34 -0700 Message-ID: <153077337481.40830.15235657458024188710.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153077334130.40830.2714147692560185329.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153077334130.40830.2714147692560185329.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huaisheng Ye direct_access needs to check the validity of pointer pfn for NULL assignment. If pfn equals to NULL, it doesn't need to calculate the value. Signed-off-by: Huaisheng Ye Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- drivers/nvdimm/pmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index e8ac6f244d2b..c430536320a5 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -228,7 +228,8 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, PFN_PHYS(nr_pages)))) return -EIO; *kaddr = pmem->virt_addr + offset; - *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + if (pfn) + *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* * If badblocks are present, limit known good range to the