Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp294853imm; Thu, 5 Jul 2018 00:00:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfHhILtvPWGucOzp4unAM0Ej+nvmH3TmlNeWrHGeY0I04CJGv3qvL1/A+D6OibUQk2AcgBH X-Received: by 2002:a62:bd03:: with SMTP id a3-v6mr5102625pff.138.1530774059731; Thu, 05 Jul 2018 00:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530774059; cv=none; d=google.com; s=arc-20160816; b=SyWsOtJ4rg+w3NePOeQdVsa4q4FvMipZxOagBUi6NTciXOIdgKzx1bzYLQcJKB2otb EyuoXTaBAflUF4BLcYp/ispkvdv1yJ18qjkRZvSwshfKcTItq2gW0gqiPTNuo5G+8Cx4 b0D7MQ2Hg5ufyER3kRTXlu8vJbLFsI+LJ2bZMN4DIYswXNd8boqOMWNRWeSXPMWAK0Yg 0Mr/bOQcWzfkWo7FNok3XAGdELyKezf2O9Vvig0OsvRJmiEWsscn78wyXM2V4Go8L38U CANBsFr0Kg0hZGpkOYcMDNFuzKgnEqNOkalIFsIHi+TEr1leRdruiiOjhwwjOaTVG1p6 j9gg== 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=bbciGCD7g5D2j3+1ToCmKRdt7ItBTTKK0praTDXMxwc=; b=ZAIlQfWp0CLwJGbJSX5VxIQZc/UZVGgBJC7w2GsSmLckX3C/Ax72WVc6lvkOJMBPCg MFM07+OToYPSmAFWnf1by4sszF+jchf6g4bYMJ4SKvwD+BKUVOaFNNdCL66EeL1ev97J h1xfXci6hkVmV67nYVQcVxHN3Y1Q7XZ/dUlDWmGRjZgH3mq1G1XbDtpg63qLjbS9Ymid LYSSAyAYyuOeY5YxvRwaFPTTKb3+D/6iYYdy95aj1VZVqeGckJ+v0aV8HS8L2clbsw+J 8HtloXVw/JK/j1Ba+uqmRb3soSJmweVjfkpWHQCTcqdkiMpHNAxsGcti/00E0Lqe+k6K DVhg== 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 f4-v6si5793892pfj.97.2018.07.05.00.00.45; Thu, 05 Jul 2018 00:00: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 S1753510AbeGEG7k (ORCPT + 99 others); Thu, 5 Jul 2018 02:59:40 -0400 Received: from mga17.intel.com ([192.55.52.151]:22798 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753401AbeGEG7i (ORCPT ); Thu, 5 Jul 2018 02:59:38 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 23:59:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,311,1526367600"; d="scan'208";a="242767670" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga005.fm.intel.com with ESMTP; 04 Jul 2018 23:59:37 -0700 Subject: [PATCH 07/13] nvdimm/pmem-dax: 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:40 -0700 Message-ID: <153077338038.40830.8894996377094953603.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. Suggested-by: Dan Williams Signed-off-by: Huaisheng Ye Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- tools/testing/nvdimm/pmem-dax.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/nvdimm/pmem-dax.c b/tools/testing/nvdimm/pmem-dax.c index b53596ad601b..d4cb5281b30e 100644 --- a/tools/testing/nvdimm/pmem-dax.c +++ b/tools/testing/nvdimm/pmem-dax.c @@ -33,7 +33,8 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, *kaddr = pmem->virt_addr + offset; page = vmalloc_to_page(pmem->virt_addr + offset); - *pfn = page_to_pfn_t(page); + if (pfn) + *pfn = page_to_pfn_t(page); pr_debug_ratelimited("%s: pmem: %p pgoff: %#lx pfn: %#lx\n", __func__, pmem, pgoff, page_to_pfn(page)); @@ -41,7 +42,8 @@ long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, } *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